BUG_insert_array_relational_db
BUG_insert_array_relational_db
Description
When we want to insert array in a relational table, we can't make with "[50.0]". It's a syntax, error.
Steps to Reproduce
Steps to reproduce the bug in a list, as many detailed as possible.
se3 = SQLEnumerable(conn, "app_star")
res = se3.insert(
[
"name",
"distance",
"spec_type",
"magnitude_v",
"mass",
"age",
"teff",
"teff_error",
"radius",
"mettalicity",
"ra",
"dec",
"status",
"import_id",
],
(
"HD 73256",
36.5,
"G8/K0",
8.08,
1.05,
0.83,
5570,
[50.0],
0.89,
0.29,
129.0958333,
-30.0375,
1,
1,
),
).execute()
Expected behavior
return 1
Actual behavior
Traceback (most recent call last):
File "/home/uchosson/Documents/exoimport/empty_db.py", line 50, in <module>
).execute()
File "/home/uchosson/.cache/pypoetry/virtualenvs/exoimport-dGwpJlCJ-py3.10/lib/python3.10/site-packages/py_linq_sql/sql_enumerable/sql_enumerable.py", line 1636, in execute
record = execute_alter(cmd_to_execute, hidden_sqle)
File "/home/uchosson/.cache/pypoetry/virtualenvs/exoimport-dGwpJlCJ-py3.10/lib/python3.10/site-packages/py_linq_sql/utils/execute.py", line 254, in execute_alter
raise DatabError(
py_linq_sql.exception.exception.DatabError: The command INSERT INTO "app_star"( name, distance, spec_type, magnitude_v, mass, age, teff, teff_error, radius, mettalicity, ra, dec, status, import_id ) VALUES ('HD 73256', 36.5, 'G8/K0', 8.08, 1.05, 0.83, 5570, [50.0], 0.89, 0.29, 129.0958333, -30.0375, 1, 1) wasn't executed.
Context : Something wrong with database.
An exception has occurred: syntax error at or near "["
LINE 1: ...HD 73256', 36.5, 'G8/K0', 8.08, 1.05, 0.83, 5570, [50.0], 0....
^
Exception TYPE: <class 'psycopg.errors.SyntaxError'>
Reproduces how often
100+
Versions
version 1.0.0.1
Additional Information
We can correct this bug with an array insertion like: https://www.postgresqltutorial.com/postgresql-tutorial/postgresql-array/