Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare with named Arguments Failing for MySQL #46

Open
mattcbro opened this issue Jul 26, 2023 · 0 comments
Open

Prepare with named Arguments Failing for MySQL #46

mattcbro opened this issue Jul 26, 2023 · 0 comments

Comments

@mattcbro
Copy link

So I have a simple test table that looks like this:

+-------+--------------+------+-----+---------+-------+
| Field | Type         | Null | Key | Default | Extra |
+-------+--------------+------+-----+---------+-------+
| id    | int(11)      | YES  |     | <null>  |       |
| pname | varchar(255) | YES  |     | <null>  |       |
+-------+--------------+------+-----+---------+-------+

I connect to the database successfully and then try to insert some values using named arguments such as this,

stmt = DBInterface.prepare(conn,"insert into test values(:id, :pname) ;")

This results in the error:

julia> stmt = DBInterface.prepare(conn,"insert into test values(:id, :pname) ;")
ERROR: (1064): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ':id, :pname)' at line 1
Stacktrace:
 [1] prepare
   @ ~/.julia/packages/MySQL/tCDUl/src/api/papi.jl:4 [inlined]
 [2] prepare(conn::MySQL.Connection, sql::String; mysql_date_and_time::Bool)
   @ MySQL ~/.julia/packages/MySQL/tCDUl/src/prepare.jl:48
 [3] prepare(conn::MySQL.Connection, sql::String)
   @ MySQL ~/.julia/packages/MySQL/tCDUl/src/prepare.jl:45
 [4] top-level scope
   @ /data/projects/Stocks/testsql.jl:17

If I use positional arguments it works fine. However positional arguments can't handle more complicated queries wherein a given argument must appear multiple times within the query.

Is this an issue within DBInterface or MySQL?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant