liquid_feedback_frontend
annotate env/encode/pg_hstore.lua @ 1072:ba51e72830e6
Added OpenLDAP license to LICENSE file
| author | bsw |
|---|---|
| date | Fri Jul 18 23:12:14 2014 +0200 (2014-07-18) |
| parents | 58f48a8a202a |
| children |
| rev | line source |
|---|---|
| bsw@1071 | 1 -- Encodes a Lua table as PostgreSQL hstore text input |
| bsw@1071 | 2 -- TODO This should be implemented in the SQL abstraction layer |
| bsw@1071 | 3 |
| bsw@1071 | 4 function encode.pg_hstore(hstore_values) |
| bsw@1071 | 5 |
| bsw@1071 | 6 local entries = {} |
| bsw@1071 | 7 |
| bsw@1071 | 8 for key, val in pairs(hstore_values) do |
| bsw@1071 | 9 local escaped_key = encode.pg_hstore_value(key) |
| bsw@1071 | 10 local escaped_val = encode.pg_hstore_value(val) |
| bsw@1071 | 11 entries[#entries+1] = escaped_key .. "=>" .. escaped_val |
| bsw@1071 | 12 end |
| bsw@1071 | 13 |
| bsw@1071 | 14 return table.concat(entries, ", ") |
| bsw@1071 | 15 |
| bsw@1071 | 16 end |