Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

Postgres problem with import

#5

Import is not working with an array of ActiveRecord instances (all I have tried so far).

The sequence generation is using the default base class code (sequence.nextval) instead of the Postgres version ("nextval('sequence')").

There is some code to do this in the lib/ar-extensions/import/postgresql.rb file, but it doesn't appear to be loaded.

The ./lib/ar-extensions/adapters/postgresql.rb in the gem is empty. Not sure if that is a problem.

Reported by Jake Morrison · August 12th, 2008 @ 07:27 AM

State: new
Milestone: none
Assigned to: Zach Dennis Zach Dennis

Activity

  1. Gary Blessington
    Gary Blessington

    See here: http://www.continuousthinking.co...

    That will get the ("nextval('sequence')") running. However, postgres imports are still executing individual sql inserts when using import.

    November 17th, 2008 @ 01:10 AM

  2. Zach Dennis
    Zach Dennis

    I haven't touched postgres in a very long time. The import functionality for postgresql was never optimized (it was very fast anyways). If this is something you can aide with I'd be happy to work with you on it. Let me know since the 0.8.x codebase is being rewritten for a 0.9 release (which will act as the RC for 1.0)

    November 26th, 2008 @ 08:16 PM

  3. Jens
    Jens
    • Tag changed from csv, import, postgres, rails2.1.0 to import, postgres

    Hi,

    please implement postgresql batch imports. I had it working using 0.8.2 by adding something like "def supports_import?; true; end" in the adapter file, but this doesn't work with 0.9.2 any more.

    Postgres import is vital for working with ar-extensions for us.
    And it does work fine, one just needs to tell the plugin that it can be used.

    Thanks!

    October 17th, 2009 @ 09:22 AM

  4. Jens
    Jens

    Hi,

    please implement postgresql batch imports. I had it working using 0.8.2 by adding something like "def supports_import?; true; end" in the adapter file, but this doesn't work with 0.9.2 any more.

    Postgres import is vital for working with ar-extensions for us.
    And it does work fine, one just needs to tell the plugin that it can be used.

    Thanks!

    October 17th, 2009 @ 09:22 AM

  5. Jens
    Jens
    • Tag changed from import, postgres to import, patch, postgres

    Hi,

    I monkey patched import support for Postgres into ar-extensions.
    Works fine so far (Postgres-8.3 from MacPorts), at least using #import_without_validations_or_callbacks (which is the only function I need so far).

    Here's a patch:

    --- a/vendor/gems/ar-extensions-0.9.2/lib/ar-extensions/adapters/postgresql.rb +++ b/vendor/gems/ar-extensions-0.9.2/lib/ar-extensions/adapters/postgresql.rb @@ -4,6 +4,9 @@ module ActiveRecord # :nodoc:

       def next_value_for_sequence(sequence_name)
         %{nextval('#{sequence_name}')}
       end
    
    • def supports_import?
    •  true
      
    • end end end end

    Same thing like in 0.8.2, also worked fine there. Please accept this patch into the main tree.

    Thanks!

    October 26th, 2009 @ 04:58 AM

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.