Commit Graph

70 Commits (master)

Author SHA1 Message Date
Denis Knauf 038a29682e import_many, import_*: returns last_inserted_id 2013-01-03 17:07:10 +01:00
Zach Dennis 6697e2b4db Ensuring that the geo spatial adapters are successfully wired up and working with base import functionality.
[#47]
2012-12-14 10:29:04 -05:00
michael groble eec20355e5 support rgeo spatial database adapter names 2012-12-14 10:08:46 -05:00
Doug Orleans d0c1055b65 Fix example in doc comment. 2012-12-14 09:59:59 -05:00
Doug Orleans 9fd19a36bd Also clear the destroyed flag after synchronizing. 2012-12-14 09:59:58 -05:00
Doug Orleans 31ff20a332 Fix failing test - clear @new_record on synchronize. 2012-12-14 09:59:58 -05:00
Dingding Ye 1ae5122642 Performance improvements.
* Serialize the column using specified coder before inserting
* Cache the ActiveRecord connection once per call to generate values SQL
* Call sequence_name last since it's more expensive
2012-12-14 09:50:36 -05:00
Zach Dennis a4f17e6d45 Merge remote-tracking branch 'chewi/scope-awareness' 2012-12-14 09:40:03 -05:00
mildmojo 43bd628e05 Fixes case-sensitive SQLite3 adapter name typos.
The SQLite3 adapter name was referenced as
`ActiveRecord::ConnectionAdapters::Sqlite3Adapter`, but the
ActiveRecord class is spelled `SQLite3Adapter` (upper-case "SQL"). As
a result, `active_record/adapters/sqlite3_adapter.rb` wasn't actually
including the methods from `adapters/sqlite3_adapter.rb` into the AR
adapter class.

This adds a test for proper inheritance and fixes the spelling of
`SQLite3Adapter`, unifying all references to the ActiveRecord version.
2012-10-01 03:08:07 -04:00
James Le Cuirot 22473145d1 Add scope-awareness feature 2012-09-20 15:15:21 +01:00
James Abley b03af0cd3e Provide more detailed error message
If we don't have a mapping for a column name, provide the column name
as well as the index in the array.
2012-09-14 14:01:00 +01:00
Zach Dennis 6182b944ef Merge pull request #56 from grzuy/support_all_or_none_records
Adds support for :all_or_none option on #import
2012-08-29 20:48:18 -07:00
Zach Dennis 0b03543612 Merge pull request #58 from alexagranov/e6cafdb23a64e68a246a838565afaecf6faf952a
The jdbcmysql_adapter was left out of the InstanceMethods refactoring.
2012-08-29 20:47:07 -07:00
Yury Velikanau 1d9b30cf83 Put together tests for seamless_database_pool adapter 2012-08-22 19:50:37 -07:00
Evan Petrie 9ee02d87ff fix file name 2012-08-22 18:44:48 -07:00
Evan Petrie cc0185abb3 make work with seamless database pool 2012-08-22 18:44:37 -07:00
Ben Pickles f12d72b0b1 Raise a useful message when a value doesn't have a corresponding column. 2012-08-19 19:41:02 +01:00
Jared Luxenberg e12f9c4951 Model#import fails to find model's primary key sequence
Fixes a bug where Model#import does not work when a model's primary key
has no associated 'sequence' in the database. If a value for the primary
key is specified, then the insert should not require a database
'sequence' to generate a value for that primary key field.
2012-08-04 17:35:50 -07:00
Gonzalo Rodriguez eac7d5f949 Adds support for :all_or_none option on #import 2012-05-19 17:40:04 -03:00
Seamus Abshere b36259af29 Solving #50 - memoize MySQL's max_allowed_packet instead of querying it every time you run .import 2012-03-20 16:40:10 -05:00
Alex Agranov e6cafdb23a somehow the jdbcmysql_adapter was left out in the refactoring that removed usage of the InstanceMethods module 2012-02-28 19:31:55 -05:00
Zach Dennis b2c71336ca Merge pull request #20 from Empact/drop_sum_sizes
Rely on ActiveSupport #sum rather than #sum_sizes
2012-01-06 15:47:53 -08:00
Yehuda Katz b5261d0225 Clean up module usage. There's no need to use InstanceMethods -- normal Ruby modules and includes will work fine here. 2012-01-03 00:41:04 -08:00
Nat Budin 08c36d33e4 Use connection pool instead of actual connection to avoid having to connect to the database until necessary 2011-10-10 13:07:10 -04:00
Ben Woosley 8d20594f12 Replace #sum_sizes with calls to ActiveSupport #sum, as splatting large numbers of values is resource intensive andcan cause stack overflows of the sort 'SystemStackError: stack level too deep' 2011-08-16 17:01:11 -07:00
Zach Dennis 5a71efa2b4 Merge pull request #21 from jamiecobbett/master
Fix import of very large datasets containing multibyte chars on Ruby 1.9
2011-06-22 19:51:29 -07:00
Zach Dennis 92ec1b478d Merge pull request #26 from fallwith/master
Ruby 1.9.2 / RubyGems 1.8.5 compatibility fix (pass String instead of Pathname to require)
2011-06-22 19:45:17 -07:00
fallwith 8f91eeb93d Regexp.escape which is called by Gem.loaded_path? (/usr/local/lib/ruby/site_ruby/1.9.1/rubygems.rb) expects the path as a String, not a Pathname. Convert Pathnames to Strings prior to calling 'require' 2011-06-22 16:01:33 -07:00
Jamie Cobbett 6555fd70ba Correctly obey MySQL MAX PACKET
Use String's bytesize instead of size, because we're talking about byte length,
not string length. This resolves a problem on Ruby 1.9 with multi-byte
characters.
2011-05-08 21:35:47 +00:00
Jason 88e2ee034b Adding jdbcmysql support. 2011-05-04 20:27:11 -04:00
Zach Dennis 5aefbb2989 Do not use ActiveRecord::Base.new(hsh) when instantiating AR models. Use form of instantiation that allows protected attributes to be set. 2011-04-29 00:13:26 -04:00
Zach Dennis 89662a67c2 Updating documentation for synchronize.
https://github.com/zdennis/activerecord-import/issues/16
2011-04-06 14:41:42 -04:00
Zach Dennis 58b144b6bf Updating documentation for synchronizing unsaved/new instances with import.
https://github.com/zdennis/activerecord-import/issues/16
2011-04-06 14:23:13 -04:00
Zach Dennis 7958ed18c2 Added :synchronize_keys to the import options so importing can synchronize on fields beside the primary key.
https://github.com/zdennis/activerecord-import/issues/16
2011-04-06 14:20:53 -04:00
Zach Dennis 319c52d80f Pulled in ActiveRecord synchronize functionality from the old ar-extensions code base.
https://github.com/zdennis/activerecord-import/issues#issue/6
2011-03-19 15:38:24 -04:00
Franck Verrot d901a7c60f Importing an empty array of objects/values should be supported 2011-03-19 15:11:28 -04:00
Zach Dennis cb6b726eac Ensure the #max_allowed_packet method exists for the MysqlAdapters.
https://github.com/zdennis/activerecord-import/issues#issue/12
2011-01-11 21:01:34 -05:00
Zach Dennis 161cf017f9 Renamed #values_sql_for_column_names_and_attributes to #values_sql_for_columns_and_attributes and cleaned up how it dealt with columns.
* added back in the support for type-casting based on the database column
* removed unused method in ActiveRecord::Import::AbstractAdapter

https://github.com/zdennis/activerecord-import/issues#issue/5
2011-01-10 22:36:52 -05:00
Ben Woosley 1a8082444b Simplify validations_arry_for_column_names_and_attributes with map, each_with_index and Hash.
Hash[column_names.zip(attributes)] would be much clearer, but would leave nil values for missing attributes which doesn't match the existing behavior.
2011-01-10 22:27:24 -05:00
Ben Woosley c9f246f4e2 Consolidate insert_sql between supports_import? cases so both make use of options[:ignore] 2011-01-10 22:27:23 -05:00
Ben Woosley 9727a04362 Reinstate the deleting of the :validate option - not because it was causing trouble, but to be a bit paranoid (reverts 63d6faeccee14b6e571a25b6f51f340d5da325f5) 2011-01-10 22:27:23 -05:00
Ben Woosley a3e9b4f040 Enable ImportSupport on Postgresql - the test suite now passes in full 2011-01-10 22:27:23 -05:00
Ben Woosley 7bd0e2693a Fix that values_sql_for_attributes wasn't accessing the columns with the same indexes as the array_of_attributes, and so was sometime mismatched.
Also return to the column_names[j] == primary_key style of testing, as the column itself is not always present
2011-01-10 22:27:22 -05:00
Ben Woosley df75eea4db Go more direct in the columns lookup 2011-01-10 22:26:39 -05:00
Ben Woosley 35786fef17 Codify import results in a Struct rather than OpenStruct, as it's a faster, more rigid structure 2011-01-10 22:12:34 -05:00
Ben Woosley 876546c584 #dup array_of_attributes a bit earlier - there's no point in duping the primary_key nulls we might put in next 2011-01-10 22:12:34 -05:00
Ben Woosley 899af1e412 No reason to pull :validate out of the options hash, and it's obfuscatory - remove. 2011-01-10 22:12:34 -05:00
Ben Woosley 18012bbbca More simplicity, once again with #map 2011-01-10 22:12:33 -05:00
Ben Woosley 3756e4f2b4 Refactor remaining supports_import? split to share code in values_sql_for_column_names_and_attributes. This means both with properly support sequences.
Rather than pass a ton of variables (sequence_name, columns, column_names, &c.), move the method out of the connection.  Also, use Column#primary to check primary key status.
2011-01-10 22:12:29 -05:00
Ben Woosley 5f4d9b3290 Extract columns_sql local more generally in #import_without_validations_or_callbacks. This is DRY-er, more consistent between the supports_import? cases and enables us to inline #quote_column_names 2011-01-10 22:11:54 -05:00