#5 new
Jake Morrison

Postgres problem with import

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

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.

Comments and changes to this ticket

  • Gary Blessington

    Gary Blessington November 17th, 2008 @ 01:10 AM

    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.

  • Zach Dennis

    Zach Dennis November 26th, 2008 @ 08:16 PM

    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)

  • Jens

    Jens October 17th, 2009 @ 09:22 AM

    • 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!

  • Jens

    Jens October 17th, 2009 @ 09:22 AM

    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!

  • Jens

    Jens October 26th, 2009 @ 04:58 AM

    • 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!

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.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

ActiveRecord::Extension (aka ar-extensions) is a plugin to extend and
enhance the functionality of ActiveRecord. It starts by adding better
find support for ActiveRecord. It then adds mass data import
capabilities which are highly efficient and lastly it supports to_csv
functionality.

It also introduces a cool concept of creating easily extendable pieces
of ActiveRecord functionality, so developers don't have to understand
ActiveRecord internals or have the fear of breaking ActiveRecord
itself.

Pages