Skip to content

Setting key = "boolean" in schema and while inserting key = false is not working #123

@p-tupe

Description

@p-tupe

Minimal example :

local sqlite = require("sqlite")

local db = sqlite {
  uri = "test_db",
  tbl = {
    ok_key = "text",
    problem_key = "boolean",
  },
}

function main()
  if (db:close()) then db:open() end

  db:insert("tbl", {
    ok_key = "this works",
    problem_key = false,
    -- this is either silently ignored and not inserted in db,
    -- or throws "Missing Key" error when set to false
  })
  db:close()
end

main()

Schema :

sqlite-test · sqlite3 test_db
SQLite version 3.36.0 2021-06-18 18:36:39
Enter ".help" for usage hints.
sqlite> .tables
tbl
sqlite> .schema tbl
CREATE TABLE tbl(ok_key text, problem_key boolean);

Trace :

luajit: /usr/local/share/lua/5.1/sqlite/assert.lua:62: sqlite.lua: (insert) missing a required key: table: 0x416e42c0
stack traceback:
	[C]: in function 'assert'
	/usr/local/share/lua/5.1/sqlite/assert.lua:62: in function 'missing_req_key'
	/usr/local/share/lua/5.1/sqlite/parser.lua:537: in function 'f'
	/usr/local/share/lua/5.1/sqlite/utils.lua:154: in function 'map'
	/usr/local/share/lua/5.1/sqlite/parser.lua:534: in function 'pre_insert'
	/usr/local/share/lua/5.1/sqlite/db.lua:443: in function 'insert'
	test.lua:14: in function 'main'
	test.lua:23: in main chunk
	[C]: at 0x55f144900c20

Environment :

  • neovim v0.5 (Stable)
  • luajit v2.0.5
  • sqlite3 v3.36
  • sqlite v1.2.0-0

Thanks for the aweome plugin btw! Please let me know if there is anything else I can provide to reproduce the issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions