Skip to content

Error when inserting certain strings with bracketsΒ #150

Description

@jghauser

I've come across a bug when running the following code:

local tbl = require("sqlite.tbl") --- for constructing sql tables
local db = require("sqlite.db") --- for constructing sql databases

-- the data table
local tbl_data = tbl("data", {
	id = true,
	test = { "text", required = true, unique = true },
})

local tbls = {
	uri = "~/test.sqlite3",
	data = tbl_data,
}

local data = db(tbls)

data.data:remove() -- to ensure tbl is empty
data.data:insert({ test = "tes(t)" })

Gives:

E5113: Error while calling lua chunk: ...im/site/pack/packer/start/sqlite.lua/lua/sqlite/stmt.lua:35
: sqlite.lua: sql statement parse, , stmt: `insert into data (test) values(tes(t))`, err: `(`no such
 column: t`)`

It only happens when

  • both opening and closing brackets are in the string
  • the closing bracket is the last char of the string

I'm guessing something isn't being escaped properly.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions