surus 0.6.1 → 0.6.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 673c1aa25cdc864726ef75d05c0b4c744e19ce46
4
- data.tar.gz: dc9cce4603873ce8bd1dc82d1f1c4327c9781693
3
+ metadata.gz: a3aff7e0e8b000df98229acb0c68f228f94ca85d
4
+ data.tar.gz: dec38237d5576383026aae08b756084686c0584b
5
5
  SHA512:
6
- metadata.gz: b15ea86cc152a4394d8053fee9f480978586cf257eb7f3f4904d071a780a3904ef5fd4bab84ab951d72ef4bb4d8304a40d9b999c29cbe9fad7d8c086d7806702
7
- data.tar.gz: 071aa66602f6d19db575cff2033f22341d9e51256d545a1fd6e22c3dda72d3095c2e8eb237ce742e419b4f1c37e045e15e8cef42d9335e0b371f8c7fcd76f796
6
+ metadata.gz: e6ffb1bbac2326e6a07ab64340d94414c68f7b34fd921b2570091a02b83638092d26381590617b8b156a108a84f5256e1c938d64c516b0b8c640c03905a41251
7
+ data.tar.gz: a38ecc94ac49448b5039f8aac1c18f665575fa912ad3a44224ac4cefc7e209adac1fb70498d4a6a8952a013fe4f4eb88aaa81d1857c4085e9873a3ecf6504e1b
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 0.6.2 (November 19, 2015)
2
+
3
+ * Prefix column name with table names in query conditions (Michał Krzyżanowski)
4
+
1
5
  # 0.6.1 (July 18, 2015)
2
6
 
3
7
  * Fix all_json and prepared statements (mathieumahe)
@@ -3,7 +3,7 @@ class InstallHstore < ActiveRecord::Migration
3
3
  version = ActiveRecord::Base.connection.send(:postgresql_version)
4
4
  # check for newer versions
5
5
  if version >= 90100
6
- sql = "CREATE EXTENSION hstore"
6
+ sql = "CREATE EXTENSION IF NOT EXISTS hstore"
7
7
  # use the hstore.sql file on the system, if found
8
8
  elsif(path = hstore_sql_path)
9
9
  sql = File.read(path)
@@ -29,7 +29,7 @@ private
29
29
  rescue Errno::ENOENT # if `pg_config` fails
30
30
  nil
31
31
  end
32
-
32
+
33
33
  def default_sql
34
34
  hstore_sql = <<-HSTORE_SQL
35
35
  /* $PostgreSQL: pgsql/contrib/hstore/hstore.sql.in,v 1.11 2009/06/11 18:30:03 tgl Exp $ */
@@ -299,6 +299,6 @@ AS
299
299
  FUNCTION 4 gin_consistent_hstore(internal, int2, internal, int4, internal, internal),
300
300
  STORAGE text;
301
301
  HSTORE_SQL
302
-
302
+
303
303
  end
304
304
  end
@@ -8,7 +8,7 @@ module Surus
8
8
  # User.array_has(:permissions, "manage_users", "manage_roles")
9
9
  # User.array_has(:permissions, ["manage_users", "manage_roles"])
10
10
  def array_has(column, *values)
11
- where("#{connection.quote_column_name(column)} @> ARRAY[?]#{array_cast(column)}", values.flatten)
11
+ where("#{connection.quote_table_name(table_name)}.#{connection.quote_column_name(column)} @> ARRAY[?]#{array_cast(column)}", values.flatten)
12
12
  end
13
13
 
14
14
  # Adds where condition that requires column to contain any values
@@ -18,7 +18,7 @@ module Surus
18
18
  # User.array_has_any(:permissions, "manage_users", "manage_roles")
19
19
  # User.array_has_any(:permissions, ["manage_users", "manage_roles"])
20
20
  def array_has_any(column, *values)
21
- where("#{connection.quote_column_name(column)} && ARRAY[?]#{array_cast(column)}", values.flatten)
21
+ where("#{connection.quote_table_name(table_name)}.#{connection.quote_column_name(column)} && ARRAY[?]#{array_cast(column)}", values.flatten)
22
22
  end
23
23
 
24
24
  private
@@ -6,33 +6,33 @@ module Surus
6
6
  # Example:
7
7
  # User.hstore_has_pairs(:properties, "favorite_color" => "green")
8
8
  def hstore_has_pairs(column, hash)
9
- where("#{connection.quote_column_name(column)} @> ?", Serializer.new.dump(hash))
9
+ where("#{connection.quote_table_name(table_name)}.#{connection.quote_column_name(column)} @> ?", Serializer.new.dump(hash))
10
10
  end
11
-
11
+
12
12
  # Adds a where condition that requires column to contain key
13
13
  #
14
14
  # Example:
15
15
  # User.hstore_has_key(:properties, "favorite_color")
16
16
  def hstore_has_key(column, key)
17
- where("#{connection.quote_column_name(column)} ? :key", :key => key)
17
+ where("#{connection.quote_table_name(table_name)}.#{connection.quote_column_name(column)} ? :key", :key => key)
18
18
  end
19
-
19
+
20
20
  # Adds a where condition that requires column to contain all keys.
21
21
  #
22
22
  # Example:
23
23
  # User.hstore_has_all_keys(:properties, "favorite_color", "favorite_song")
24
24
  # User.hstore_has_all_keys(:properties, ["favorite_color", "favorite_song"])
25
25
  def hstore_has_all_keys(column, *keys)
26
- where("#{connection.quote_column_name(column)} ?& ARRAY[:keys]", :keys => keys.flatten)
26
+ where("#{connection.quote_table_name(table_name)}.#{connection.quote_column_name(column)} ?& ARRAY[:keys]", :keys => keys.flatten)
27
27
  end
28
-
28
+
29
29
  # Adds a where condition that requires column to contain any keys.
30
30
  #
31
31
  # Example:
32
32
  # User.hstore_has_any_keys(:properties, "favorite_color", "favorite_song")
33
33
  # User.hstore_has_any_keys(:properties, ["favorite_color", "favorite_song"])
34
34
  def hstore_has_any_keys(column, *keys)
35
- where("#{connection.quote_column_name(column)} ?| ARRAY[:keys]", :keys => keys.flatten)
35
+ where("#{connection.quote_table_name(table_name)}.#{connection.quote_column_name(column)} ?| ARRAY[:keys]", :keys => keys.flatten)
36
36
  end
37
37
  end
38
38
  end
data/lib/surus/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Surus
2
- VERSION = "0.6.1"
2
+ VERSION = "0.6.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: surus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jack Christensen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-18 00:00:00.000000000 Z
11
+ date: 2015-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -243,8 +243,19 @@ required_rubygems_version: !ruby/object:Gem::Requirement
243
243
  version: '0'
244
244
  requirements: []
245
245
  rubyforge_project: ''
246
- rubygems_version: 2.4.5
246
+ rubygems_version: 2.4.5.1
247
247
  signing_key:
248
248
  specification_version: 4
249
249
  summary: PostgreSQL Acceleration for ActiveRecord
250
- test_files: []
250
+ test_files:
251
+ - spec/array/scope_spec.rb
252
+ - spec/database.yml
253
+ - spec/database.yml.travis
254
+ - spec/database_structure.sql
255
+ - spec/factories.rb
256
+ - spec/hstore/scope_spec.rb
257
+ - spec/hstore/serializer_spec.rb
258
+ - spec/json/json_spec.rb
259
+ - spec/spec_helper.rb
260
+ - spec/synchronous_commit/connection_spec.rb
261
+ - spec/synchronous_commit/model_spec.rb