rubydb-activerecord 0.1.0 → 0.1.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
  SHA256:
3
- metadata.gz: becb1537aee9af710911f9a816a27b272dc5bde4889dbed351c1131ba9184224
4
- data.tar.gz: dc0e6243c319dbaaa738a0470032655f772fa98339de1af8f24066b66e321e3e
3
+ metadata.gz: 9f847d51451d08f816663e0a89bba24ae799218703f97ac2cc87f433148d2989
4
+ data.tar.gz: 75477ea1015dec780e069e0835a221d718f39c3126605b6c1a65da7119ba8825
5
5
  SHA512:
6
- metadata.gz: 72aeae225241636cfa38e01553fa35a79a0d411330ef1bd894d8bbf88f5497e900e71924db4f7cf5b7bb797ab974e4d07f316cea6b3d56255a75314aaafe6db3
7
- data.tar.gz: e09c7ce51be379034426dc82f7047b74a954b8979d6c716f37cca70d6add2669158f9f552b688adad67aa501959fa54c2a89d4e1b28dafaca3bd50b58dbb971f
6
+ metadata.gz: 3fe49d3b1b24296ffc67df1266cbb0acaf9a6e0ec747c684f2fab777a107c0e0eb31d5eed29a35d3cd1051a4cc75e965a7edf265a52e5dc69ef676f30e287ecc
7
+ data.tar.gz: 41b717bac47ade8260f6376b1b175652b9e48c74ba3dec071770641f6b4f0b691449131123a4365acf5ed1979869ffd0b62f989e3df2023ef5c31fb908d06ea4
@@ -249,7 +249,10 @@ module ActiveRecord
249
249
  log(sql, name) do
250
250
  params = bind_values(binds)
251
251
  result = @connection.execute(sql, params)
252
- id = result.row_id
252
+ # RubyDB keeps a physical row id for storage operations and a
253
+ # logical primary-key value for SQL/ActiveRecord. They can differ
254
+ # after deletes, so ActiveRecord must receive the logical id.
255
+ id = result.inserted_id || result.row_id
253
256
  ActiveRecord::Result.new([pk || "id"], id.nil? ? [] : [[id]])
254
257
  end
255
258
  end
@@ -756,10 +759,15 @@ module ActiveRecord
756
759
 
757
760
  # ActiveRecord's generic Column deduplication is string-oriented. RubyDB
758
761
  # persists typed defaults, so serialize scalar defaults at this boundary
759
- # and let ActiveRecord cast them through the column type map.
760
- def rails_default_value(value)
761
- value.is_a?(String) ? value : value.to_s
762
- end
762
+ # and let ActiveRecord cast them through the column type map.
763
+ def rails_default_value(value)
764
+ # RubyDB exposes SQL defaults as AST literals. ActiveRecord expects
765
+ # the scalar payload when it builds its Column metadata; calling
766
+ # `to_s` on the wrapper would leak the Ruby object inspection into
767
+ # newly instantiated records.
768
+ value = value.value if value.respond_to?(:value) && !value.is_a?(String)
769
+ value.is_a?(String) ? value : value.to_s
770
+ end
763
771
 
764
772
  def sql_for_execution(sql)
765
773
  sql = sql.to_sql if sql.respond_to?(:to_sql)
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "rubydb-activerecord"
5
- spec.version = "0.1.0"
5
+ spec.version = "0.1.2"
6
6
  spec.authors = ["Aldane Hutchinson"]
7
7
  spec.email = ["aldanehutchinson5@gmail.com"]
8
8
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubydb-activerecord
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aldane Hutchinson