table: Fix use of numbered argument placeholders

go-sqlite3 does not implement them properly (in fact, the proper support
was just removed, wtf, mattn). Additionally, go-sqlite3 does not handle
$name or @name properly despite these being supported by SQLite, only
:name works.

Closes #241.
This commit is contained in:
fox.cpp 2020-06-19 14:09:48 +03:00
parent 3fc8a54924
commit 071d06dbff
No known key found for this signature in database
GPG key ID: 5B991F6215D2FCC0
4 changed files with 12 additions and 12 deletions

View file

@ -67,11 +67,11 @@ func (s *SQLTable) Init(cfg *config.Map) error {
},
{
Name: "lookup",
Args: []string{fmt.Sprintf("SELECT %s FROM %s WHERE %s = $1", valueColumn, tableName, keyColumn)},
Args: []string{fmt.Sprintf("SELECT %s FROM %s WHERE %s = :key", valueColumn, tableName, keyColumn)},
},
{
Name: "add",
Args: []string{fmt.Sprintf("INSERT INTO %s(%s, %s) VALUES($1, $2)", tableName, keyColumn, valueColumn)},
Args: []string{fmt.Sprintf("INSERT INTO %s(%s, %s) VALUES(:key, :value)", tableName, keyColumn, valueColumn)},
},
{
Name: "list",
@ -79,11 +79,11 @@ func (s *SQLTable) Init(cfg *config.Map) error {
},
{
Name: "set",
Args: []string{fmt.Sprintf("UPDATE %s SET %s = $2 WHERE %s = $1", tableName, valueColumn, keyColumn)},
Args: []string{fmt.Sprintf("UPDATE %s SET %s = :value WHERE %s = :key", tableName, valueColumn, keyColumn)},
},
{
Name: "del",
Args: []string{fmt.Sprintf("DELETE FROM %s WHERE %s = $1", tableName, keyColumn)},
Args: []string{fmt.Sprintf("DELETE FROM %s WHERE %s = :key", tableName, keyColumn)},
},
{
Name: "init",