Adding a custom entity, but it does not work

I added a custom entity, and created the dao file as below.

-- daos.lua
local typedefs = require "kong.db.schema.typedefs"

return {
    -- this plugin only results in one custom DAO, named `rbac_user_roles`:
    rbac_user_roles = {
        name = "rbac_user_roles", -- the actual table in the database
        endpoint_key = "user_id",
        primary_key = { "user_id" },
        cache_key = { "user_id" },
        generate_admin_api = true,
        admin_api_name = "user-roles",
        admin_api_nested_name = "user-role",
        fields = {
            { user_id = { type = "string", required = true, unique = true } },
            { roles = { type = "set", elements = { type = "string" }, required = true } },
            { comment = { type = "string", required = false } },
            {
                -- also interted by the DAO itself
                created_at = typedefs.auto_timestamp_s,
            },
        },
    },
}

When i access the admin url /user-roles/xx, I get the following error.

What did I miss anything? Sorry for my poor english.

2019/12/19 20:37:02 [error] 31#0: *43 lua coroutine: runtime error: …local/share/lua/5.1/kong/db/strategies/postgres/init.lua:495: attempt to index local ‘statement’ (a nil value)
stack traceback:
coroutine 0:
…local/share/lua/5.1/kong/db/strategies/postgres/init.lua: in function ‘execute’
…local/share/lua/5.1/kong/db/strategies/postgres/init.lua:743: in function ‘select_by_field’
/usr/local/share/lua/5.1/kong/db/dao/init.lua:577: in function ‘select_entity’
/usr/local/share/lua/5.1/kong/api/endpoints.lua:405: in function ‘fn’
/usr/local/share/lua/5.1/kong/api/api_helpers.lua:257: in function </usr/local/share/lua/5.1/kong/api/api_helpers.lua:240>
coroutine 1:
[C]: in function ‘resume’
/usr/local/share/lua/5.1/lapis/application.lua:397: in function ‘handler’
/usr/local/share/lua/5.1/lapis/application.lua:130: in function ‘resolve’
/usr/local/share/lua/5.1/lapis/application.lua:167: in function </usr/local/share/lua/5.1/lapis/application.lua:165>
[C]: in function ‘xpcall’
/usr/local/share/lua/5.1/lapis/application.lua:173: in function ‘dispatch’
/usr/local/share/lua/5.1/lapis/nginx.lua:230: in function ‘serve’
/usr/local/share/lua/5.1/kong/init.lua:1122: in function ‘admin_content’
content_by_lua(nginx-kong.conf:189):2: in main chunk, client: xxxx, server: kong_admin, request: “GET /user-roles/k HTTP/1.1”, host: “xxxx:8001”
2019/12/19 20:37:02 [error] 31#0: *43 [lua] api_helpers.lua:422: handle_error(): /usr/local/share/lua/5.1/lapis/application.lua:401: …local/share/lua/5.1/kong/db/strategies/postgres/init.lua:495: attempt to index local ‘statement’ (a nil value)


© 2019 Kong Inc.    Terms  •  Privacy  •  FAQ