GithubHelp home page GithubHelp logo

Comments (5)

rkrage avatar rkrage commented on July 22, 2024

Hi @rogozin, thanks for reporting this.

Just curious, is there a specific reason you're calling model_name here? The in_partition method currently returns an ActiveRecord::Relation. The anonymous class wasn't really meant to be leaked and interacted with (outside of chaining query methods).

But I think you're right, delegating name to the parent class seems like a reasonable thing to do.

from pg_party.

rogozin avatar rogozin commented on July 22, 2024

Hi @rkrage, thanks for your answer 👍

Frankly I'm using activerecord-import with ON CONFILCT expression, so in fact I'm calling

TMainDatum.import huge_data_array, on_duplicate_key_update: { target_and_column_options } 

And of course it won't work because there are PG partition restrictions for on_conflict usage .

Eventually I'm targeting specific partition like this:

TMainDatum.in_partition('t_main_data_2017_34').import huge_data_array, on_duplicate_key_update: { target_and_column_options }

and it works well, but the only exception as I've described above :)

from pg_party.

rkrage avatar rkrage commented on July 22, 2024

Ah, okay. Honestly, I didn't think a whole lot about use cases for in_partition. Maybe it makes sense to change the API a little bit then - have it return the raw child class so users can interact with it directly?

I have a pull request up that fixes the bug (#14), but I'll try to revise it a bit to reflect this API change.

Sound good?

from pg_party.

rkrage avatar rkrage commented on July 22, 2024

Side note, if it sounds like in_partition will be a widely used method, we might want to consider adding a bit of validation (check that the partition is actually a child partition of the parent), and add some class caching (to reduce the amount of child classes that are dynamically created).

Sounds like that work should be in a separate PR though.

from pg_party.

rkrage avatar rkrage commented on July 22, 2024

@rogozin the fix should be included in version 0.6.0

from pg_party.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.