leafo / pgmoon

A pure Lua Postgres driver for use in OpenResty & more
MIT License
391 stars 93 forks source link

when i select data from pg10, some column does't display #71

Closed forkforlearn closed 6 years ago

forkforlearn commented 6 years ago

My table has three column

CREATE TABLE public.test_nextid
(
  id  serial,
  name character varying(255),
  desc character varying(255)
)

And i insert one recorder

inert into test_nextid (name) values("testname_1")

And i select all data from the table

        local sql = "select * from test_nextid"
        res,err = assert_error(db.query(sql))
        --res,err = db.select("* from test_nextid")

But there is no desc in result.... I want to see the "desc " column in the result,what should i do? thank u

Leorex commented 6 years ago

"desc" is a reserved word in PostgreSQL, so you should name your column something else, like "dsc" or "description".

leafo commented 6 years ago

NULL is converted to nil in Lua, and nil values don't exist in a table so they aren't in there.

https://github.com/leafo/pgmoon#converting-nulls

@Leorex that is not an issue, and you can use escape_identifier to use any string as a column name