liquid_feedback_frontend
diff env/encode/pg_hstore.lua @ 1071:58f48a8a202a
Imported and merged LDAP patch
| author | bsw |
|---|---|
| date | Fri Jul 18 21:42:59 2014 +0200 (2014-07-18) |
| parents | |
| children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/env/encode/pg_hstore.lua Fri Jul 18 21:42:59 2014 +0200 1.3 @@ -0,0 +1,16 @@ 1.4 +-- Encodes a Lua table as PostgreSQL hstore text input 1.5 +-- TODO This should be implemented in the SQL abstraction layer 1.6 + 1.7 +function encode.pg_hstore(hstore_values) 1.8 + 1.9 + local entries = {} 1.10 + 1.11 + for key, val in pairs(hstore_values) do 1.12 + local escaped_key = encode.pg_hstore_value(key) 1.13 + local escaped_val = encode.pg_hstore_value(val) 1.14 + entries[#entries+1] = escaped_key .. "=>" .. escaped_val 1.15 + end 1.16 + 1.17 + return table.concat(entries, ", ") 1.18 + 1.19 +end