pg_conn 0.13.1 → 0.13.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pg_conn/version.rb +1 -1
- data/lib/pg_conn.rb +16 -2
- 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: 5a1eb7cce679245ec285129507e3d56948c2239b930ea18a757dd90c2e293404
|
4
|
+
data.tar.gz: c60efa88bb84530b91a58fd296781052b500968010808f9fa2c3dca4873db772
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de7cea3519b5dbd3763c24681ed917ae525fb87e359bc17461e0c950cc70ea47d3c79e230840d878a14533b7921a55384bf17235d32020787e22c37b8fb5e16c
|
7
|
+
data.tar.gz: 6dde3d8a9ea145db3e28b2467df50333042f3243da9d7b741e1195bb2d17856577541ff8df09744cc94517f9e02c7e6de44eba52fb3ba0ca363d0103edc89d13
|
data/lib/pg_conn/version.rb
CHANGED
data/lib/pg_conn.rb
CHANGED
@@ -562,14 +562,28 @@ module PgConn
|
|
562
562
|
def update(schema = nil, table, expr, hash)
|
563
563
|
table = [schema, table].compact.join(".")
|
564
564
|
assignments = hash.map { |k,v| "#{k} = #{quote_literal(v)}" }.join(", ")
|
565
|
-
constraint =
|
565
|
+
constraint =
|
566
|
+
case expr
|
567
|
+
when String; expr
|
568
|
+
when Integer; "id = #{quote_literal(expr)}"
|
569
|
+
when Array; "id in #{quote_literal_list(expr)}"
|
570
|
+
else
|
571
|
+
raise ArgumentError
|
572
|
+
end
|
566
573
|
exec %(update #{table} set #{assignments} where #{constraint})
|
567
574
|
end
|
568
575
|
|
569
576
|
# Delete record(s)
|
570
577
|
def delete(schema = nil, table, expr)
|
571
578
|
table = [schema, table].compact.join(".")
|
572
|
-
constraint =
|
579
|
+
constraint =
|
580
|
+
case expr
|
581
|
+
when String; expr
|
582
|
+
when Integer; "id = #{quote_literal(expr)}"
|
583
|
+
when Array; "id in #{quote_literal_list(expr)}"
|
584
|
+
else
|
585
|
+
raise ArgumentError
|
586
|
+
end
|
573
587
|
exec %(delete from #{table} where #{constraint})
|
574
588
|
end
|
575
589
|
|