positioning 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ea25e9b2c25e0268da3078ed8b9d9d992aa4d4e67020f5ae317e2cdf9fa5fd10
4
- data.tar.gz: ac3996e32d7b6936a9d97d486bd63cab73c371eed718bec034bb420c262f36c1
3
+ metadata.gz: e9a6be17ba30233c2d789bbc32055280262feee10c5cef80badc42f18b829f13
4
+ data.tar.gz: 68e477089f16ad23111bc8e5e39f43f8c2bcac389b04ee5855d0729d1a50771f
5
5
  SHA512:
6
- metadata.gz: 2f0fd43a324b0629b689658b26ecec629e8103823c2a275ee24c303c2583a91b09e9599a09d5759e5236ce9cc888e7320bff5c04771ab60b2c697340bbbf1b41
7
- data.tar.gz: b752f5801180797144f8bce5ea5437495769d95522fc67213a89d953ca71fd4212c4ff08240b42c30d554d847fa56611cf84e743869d682a1d52276fec074ae6
6
+ metadata.gz: 6cce0ad940005e740b64c858250e425307578aa37697f35258f886acdb9de31954db04bc73589dd0931cc6665b1f5e5ddf0439f195ea0caa6010a66eed1f882d
7
+ data.tar.gz: 9f9a8587420495b693b340bd8108328116fb2414b7879ab90be3e8e2b2740346730fff4e5434c3bb951aead42d739c23fcb409d62843eea6bf73318b96e4724e
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.2.1] - 2024-04-08
4
+
5
+ - Fetch the adapter_name from #connection_db_config (@tijn)
6
+ - Use `quote_table_name_for_assignment` in `update_all` calls to guard against reserved word column names.
7
+
3
8
  ## [0.2.0] - 2024-03-12
4
9
 
5
10
  - Add an Advisory Lock to ensure isolation for the entirety of the create, update, and destroy cycles.
@@ -12,17 +12,17 @@ module Positioning
12
12
  @column = column.to_s
13
13
 
14
14
  @adapters = {
15
- "Mysql2" => Adapter.new(
15
+ "mysql2" => Adapter.new(
16
16
  initialise: -> {},
17
17
  aquire: -> { connection.execute "SELECT GET_LOCK(#{connection.quote(lock_name)}, -1)" },
18
18
  release: -> { connection.execute "SELECT RELEASE_LOCK(#{connection.quote(lock_name)})" }
19
19
  ),
20
- "PostgreSQL" => Adapter.new(
20
+ "postgresql" => Adapter.new(
21
21
  initialise: -> {},
22
22
  aquire: -> { connection.execute "SELECT pg_advisory_lock(#{lock_name.hex & 0x7FFFFFFFFFFFFFFF})" },
23
23
  release: -> { connection.execute "SELECT pg_advisory_unlock(#{lock_name.hex & 0x7FFFFFFFFFFFFFFF})" }
24
24
  ),
25
- "SQLite" => Adapter.new(
25
+ "sqlite3" => Adapter.new(
26
26
  initialise: -> {
27
27
  FileUtils.mkdir_p "#{Dir.pwd}/tmp"
28
28
  filename = "#{Dir.pwd}/tmp/#{lock_name}.lock"
@@ -63,7 +63,7 @@ module Positioning
63
63
  end
64
64
 
65
65
  def adapter_name
66
- connection.adapter_name
66
+ base_class.connection_db_config.adapter
67
67
  end
68
68
 
69
69
  def adapter
@@ -56,6 +56,10 @@ module Positioning
56
56
  @positioned.send primary_key_column
57
57
  end
58
58
 
59
+ def quoted_column
60
+ base_class.connection.quote_table_name_for_assignment base_class.table_name, @column
61
+ end
62
+
59
63
  def record_scope
60
64
  base_class.where("#{primary_key_column}": primary_key)
61
65
  end
@@ -86,13 +90,13 @@ module Positioning
86
90
  end
87
91
 
88
92
  def expand(scope, range)
89
- scope.where("#{@column}": range).update_all "#{@column} = #{@column} * -1"
90
- scope.where("#{@column}": ..-1).update_all "#{@column} = #{@column} * -1 + 1"
93
+ scope.where("#{@column}": range).update_all "#{quoted_column} = #{quoted_column} * -1"
94
+ scope.where("#{@column}": ..-1).update_all "#{quoted_column} = #{quoted_column} * -1 + 1"
91
95
  end
92
96
 
93
97
  def contract(scope, range)
94
- scope.where("#{@column}": range).update_all "#{@column} = #{@column} * -1"
95
- scope.where("#{@column}": ..-1).update_all "#{@column} = #{@column} * -1 - 1"
98
+ scope.where("#{@column}": range).update_all "#{quoted_column} = #{quoted_column} * -1"
99
+ scope.where("#{@column}": ..-1).update_all "#{quoted_column} = #{quoted_column} * -1 - 1"
96
100
  end
97
101
 
98
102
  def solidify_position
@@ -1,3 +1,3 @@
1
1
  module Positioning
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: positioning
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brendon Muir
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-03-12 00:00:00.000000000 Z
11
+ date: 2024-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport