Skip to content

bind!() fails against named parameters #104

@yuttie

Description

@yuttie
using SQLite
db = SQLite.DB("test.sqlite")
SQLite.execute!(db, "CREATE TABLE IF NOT EXISTS tbl(a  INTEGER);")
stmt = SQLite.Stmt(db, "INSERT INTO tbl (a) VALUES (@a);")
SQLite.bind!(stmt, "@a", 1)

This code produces the following output:

$ julia bug.jl
ERROR: LoadError: MethodError: `bind!` has no method matching bind!(::SQLite.Stmt, ::Int32, ::Int64)
Closest candidates are:
  bind!(::SQLite.Stmt, !Matched::AbstractString, ::Any)
  bind!(::SQLite.Stmt, !Matched::Int64, ::Int64)
  bind!(::SQLite.Stmt, !Matched::Int64, ::Any)
  ...
 in bind! at /home/someone/.julia/v0.4/SQLite/src/SQLite.jl:122
while loading /home/someone/bug.jl, in expression starting on line 5

It seems that the function sqlite3_bind_parameter_index() returns an Int32 value as a translated index for the named parameter @a, and thus the function bind!() rejects the argument.

I think we need to convert the translated index into an Int64 value or make bind!() accept an Int32 index as the second argument.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions