tina4ruby 3.10.66 → 3.10.67
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 +4 -4
- data/lib/tina4/orm.rb +6 -20
- data/lib/tina4/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e5ba81bb86f837e23521b7b13d2ee313a0ac7e34bbf04371c4256d00b077c7f3
|
|
4
|
+
data.tar.gz: 9bb8a43825801b904b30bddcfbc51fedc74694bb04d37d404d33702338d40806
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 29819ac550ac637dbc6bd3fb3456e426a2311cdbabc6cbe9953d4b03317ecb5eca6f55f5f70b69f515db433135b221fb45320f7aad3ded354b56a9772f150da2
|
|
7
|
+
data.tar.gz: 2ae5fc934297b48c3352aab9bc6606dba1553adc91e989efe8b301a6163e291eeec9f79d592a2a781ea34528b13b75a6cf8d55714f4795b5da80984c9be6e165
|
data/lib/tina4/orm.rb
CHANGED
|
@@ -481,29 +481,15 @@ module Tina4
|
|
|
481
481
|
errors
|
|
482
482
|
end
|
|
483
483
|
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
# Determine the SQL to execute
|
|
490
|
-
if filter_sql.nil? || filter_sql.is_a?(Integer)
|
|
491
|
-
# Legacy: load by primary key (load() or load(id))
|
|
492
|
-
id = filter_sql || __send__(pk)
|
|
493
|
-
return false unless id
|
|
494
|
-
sql = "SELECT * FROM #{self.class.table_name} WHERE #{pk} = ?"
|
|
495
|
-
query_params = [id]
|
|
496
|
-
else
|
|
497
|
-
# Filter-based: load("email = ?", ["alice@example.com"])
|
|
498
|
-
sql = "SELECT * FROM #{self.class.table_name} WHERE #{filter_sql}"
|
|
499
|
-
query_params = params
|
|
500
|
-
end
|
|
501
|
-
|
|
502
|
-
result = self.class.db.fetch_one(sql, query_params)
|
|
484
|
+
# Load a record into this instance via select_one.
|
|
485
|
+
# Returns true if found and loaded, false otherwise.
|
|
486
|
+
def load(sql, params = [], include: nil)
|
|
487
|
+
@relationship_cache = {}
|
|
488
|
+
result = self.class.select_one(sql, params, include: include)
|
|
503
489
|
return false unless result
|
|
504
490
|
|
|
505
491
|
mapping_reverse = self.class.field_mapping.invert
|
|
506
|
-
result.each do |key, value|
|
|
492
|
+
result.to_h.each do |key, value|
|
|
507
493
|
attr_name = mapping_reverse[key.to_s] || key
|
|
508
494
|
setter = "#{attr_name}="
|
|
509
495
|
__send__(setter, value) if respond_to?(setter)
|
data/lib/tina4/version.rb
CHANGED