upsert 2.1.0 → 2.9.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. checksums.yaml +5 -5
  2. data/.ruby-version +1 -0
  3. data/.standard.yml +1 -0
  4. data/.travis.yml +60 -12
  5. data/CHANGELOG +39 -0
  6. data/Gemfile +12 -1
  7. data/LICENSE +3 -1
  8. data/README.md +47 -6
  9. data/Rakefile +7 -1
  10. data/lib/upsert.rb +54 -11
  11. data/lib/upsert/column_definition/mysql.rb +2 -2
  12. data/lib/upsert/column_definition/postgresql.rb +9 -8
  13. data/lib/upsert/column_definition/sqlite3.rb +3 -3
  14. data/lib/upsert/connection/Java_ComMysqlJdbc_JDBC4Connection.rb +11 -5
  15. data/lib/upsert/connection/Java_OrgPostgresqlJdbc_PgConnection.rb +33 -0
  16. data/lib/upsert/connection/PG_Connection.rb +10 -1
  17. data/lib/upsert/connection/jdbc.rb +20 -1
  18. data/lib/upsert/connection/postgresql.rb +2 -3
  19. data/lib/upsert/merge_function.rb +5 -4
  20. data/lib/upsert/merge_function/Java_OrgPostgresqlJdbc_PgConnection.rb +27 -0
  21. data/lib/upsert/merge_function/PG_Connection.rb +11 -42
  22. data/lib/upsert/merge_function/postgresql.rb +215 -1
  23. data/lib/upsert/merge_function/sqlite3.rb +10 -0
  24. data/lib/upsert/version.rb +1 -1
  25. data/spec/active_record_upsert_spec.rb +10 -0
  26. data/spec/correctness_spec.rb +34 -5
  27. data/spec/database_functions_spec.rb +16 -9
  28. data/spec/database_spec.rb +7 -0
  29. data/spec/hstore_spec.rb +56 -55
  30. data/spec/jruby_spec.rb +9 -0
  31. data/spec/logger_spec.rb +8 -6
  32. data/spec/postgresql_spec.rb +94 -0
  33. data/spec/reserved_words_spec.rb +21 -17
  34. data/spec/sequel_spec.rb +26 -7
  35. data/spec/spec_helper.rb +251 -92
  36. data/spec/speed_spec.rb +3 -32
  37. data/spec/threaded_spec.rb +35 -12
  38. data/spec/type_safety_spec.rb +2 -1
  39. data/travis/install_postgres.sh +18 -0
  40. data/travis/run_docker_db.sh +20 -0
  41. data/travis/tune_mysql.sh +7 -0
  42. data/upsert-java.gemspec +13 -0
  43. data/upsert.gemspec +9 -57
  44. data/upsert.gemspec.common +107 -0
  45. metadata +53 -40
  46. data/lib/upsert/connection/Java_OrgPostgresqlJdbc4_Jdbc4Connection.rb +0 -15
  47. data/lib/upsert/merge_function/Java_OrgPostgresqlJdbc4_Jdbc4Connection.rb +0 -39
@@ -1,15 +0,0 @@
1
- require 'upsert/connection/jdbc'
2
-
3
- class Upsert
4
- class Connection
5
- # @private
6
- class Java_OrgPostgresqlJdbc4_Jdbc4Connection < Connection
7
- include Jdbc
8
- include Postgresql
9
-
10
- def quote_ident(k)
11
- DOUBLE_QUOTE + k.to_s.gsub(DOUBLE_QUOTE, '""') + DOUBLE_QUOTE
12
- end
13
- end
14
- end
15
- end
@@ -1,39 +0,0 @@
1
- require 'upsert/merge_function/postgresql'
2
-
3
- class Upsert
4
- class MergeFunction
5
- # @private
6
- class Java_OrgPostgresqlJdbc4_Jdbc4Connection < MergeFunction
7
- include Postgresql
8
-
9
- def execute(row)
10
- first_try = true
11
- values = []
12
- values += row.selector.values
13
- values += row.setter.values
14
- hstore_delete_handlers.each do |hstore_delete_handler|
15
- values << row.hstore_delete_keys.fetch(hstore_delete_handler.name, [])
16
- end
17
- begin
18
- connection.execute sql, values.map { |v| connection.bind_value v }
19
- rescue org.postgresql.util.PSQLException => pg_error
20
- if pg_error.message =~ /function #{name}.* does not exist/i
21
- if first_try
22
- Upsert.logger.info %{[upsert] Function #{name.inspect} went missing, trying to recreate}
23
- first_try = false
24
- create!
25
- retry
26
- else
27
- Upsert.logger.info %{[upsert] Failed to create function #{name.inspect} for some reason}
28
- raise pg_error
29
- end
30
- else
31
- raise pg_error
32
- end
33
- end
34
- end
35
-
36
-
37
- end
38
- end
39
- end