upsert 2.1.0 → 2.9.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.ruby-version +1 -0
- data/.standard.yml +1 -0
- data/.travis.yml +60 -12
- data/CHANGELOG +39 -0
- data/Gemfile +12 -1
- data/LICENSE +3 -1
- data/README.md +47 -6
- data/Rakefile +7 -1
- data/lib/upsert.rb +54 -11
- data/lib/upsert/column_definition/mysql.rb +2 -2
- data/lib/upsert/column_definition/postgresql.rb +9 -8
- data/lib/upsert/column_definition/sqlite3.rb +3 -3
- data/lib/upsert/connection/Java_ComMysqlJdbc_JDBC4Connection.rb +11 -5
- data/lib/upsert/connection/Java_OrgPostgresqlJdbc_PgConnection.rb +33 -0
- data/lib/upsert/connection/PG_Connection.rb +10 -1
- data/lib/upsert/connection/jdbc.rb +20 -1
- data/lib/upsert/connection/postgresql.rb +2 -3
- data/lib/upsert/merge_function.rb +5 -4
- data/lib/upsert/merge_function/Java_OrgPostgresqlJdbc_PgConnection.rb +27 -0
- data/lib/upsert/merge_function/PG_Connection.rb +11 -42
- data/lib/upsert/merge_function/postgresql.rb +215 -1
- data/lib/upsert/merge_function/sqlite3.rb +10 -0
- data/lib/upsert/version.rb +1 -1
- data/spec/active_record_upsert_spec.rb +10 -0
- data/spec/correctness_spec.rb +34 -5
- data/spec/database_functions_spec.rb +16 -9
- data/spec/database_spec.rb +7 -0
- data/spec/hstore_spec.rb +56 -55
- data/spec/jruby_spec.rb +9 -0
- data/spec/logger_spec.rb +8 -6
- data/spec/postgresql_spec.rb +94 -0
- data/spec/reserved_words_spec.rb +21 -17
- data/spec/sequel_spec.rb +26 -7
- data/spec/spec_helper.rb +251 -92
- data/spec/speed_spec.rb +3 -32
- data/spec/threaded_spec.rb +35 -12
- data/spec/type_safety_spec.rb +2 -1
- data/travis/install_postgres.sh +18 -0
- data/travis/run_docker_db.sh +20 -0
- data/travis/tune_mysql.sh +7 -0
- data/upsert-java.gemspec +13 -0
- data/upsert.gemspec +9 -57
- data/upsert.gemspec.common +107 -0
- metadata +53 -40
- data/lib/upsert/connection/Java_OrgPostgresqlJdbc4_Jdbc4Connection.rb +0 -15
- 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
|