chair 1.1.2 → 1.1.3
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/chair/chair.rb +14 -12
- data/lib/chair/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 135fd8455ba29a7242581126e4be1786da3a40b1
|
4
|
+
data.tar.gz: 842cf58875a5aa9170d61eda5ecfac19b8c3e9b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 09b8b0804f473c9553fa4c046b634e79ccb434cb8e42cc46cb664d7193ef13c91d421da33a31f24ba86e51cdff940b4d7b79d84a031ff68068f2f4170d87bd49
|
7
|
+
data.tar.gz: db63d49dd58a13a769d0e8b3eefdd3f6b4c43337709f358d32f064767d1382e80bbc666174bb4c5e8f6b1ff30ddc4e446ffcca5627e35ec09bc62b3a5e34991d
|
data/lib/chair/chair.rb
CHANGED
@@ -215,20 +215,22 @@ class Chair
|
|
215
215
|
end
|
216
216
|
# For each key, value
|
217
217
|
map.each_pair do |key, val|
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
218
|
+
if @pk_map.include? key
|
219
|
+
# if we do, check if the row has a value in the column
|
220
|
+
row = @table[@pk_map[key]]
|
221
|
+
# if it does, can we overwrite?
|
222
|
+
if row.has_attribute?(column) and not opts[:overwrite]
|
223
|
+
raise "Value already exists in table for primary key #{key.inspect} and column #{column.inspect}"
|
224
|
+
end
|
225
|
+
# if so, overwrite
|
226
|
+
row[column] = val
|
227
|
+
else # Check if we have the key in our pk_map. if not,
|
228
|
+
if opts[:create_row] # if we can create rows,
|
229
|
+
insert! @primary_key => key, column => val # create a row
|
230
|
+
else
|
231
|
+
raise "No such row with primary key #{key.inspect} exists" # or raise an error
|
222
232
|
end
|
223
233
|
end
|
224
|
-
# if we do, check if the row has a value in the column
|
225
|
-
row = @table[@pk_map[key]]
|
226
|
-
# if it does, can we overwrite?
|
227
|
-
if row.has_attribute?(column) and not opts[:overwrite]
|
228
|
-
raise "Value already exists in table for primary key #{key.inspect} and column #{column.inspect}"
|
229
|
-
end
|
230
|
-
# if so, overwrite
|
231
|
-
row[column] = val
|
232
234
|
end
|
233
235
|
self
|
234
236
|
end
|
data/lib/chair/version.rb
CHANGED