Skip to content

db_api: parse_insert method doesn't work as expected #232

@HemangChothani

Description

@HemangChothani

As mentioned in the docstring Case c return the dict with the info like homogenous, homogenous etc:

Case c)
SQL: INSERT INTO T (f1, f2) VALUES (%s, %s), (%s, %s)
Params: ['a', 'b', 'c', 'd']
it produces:
{
'homogenous': True,
'table': 'T',
'columns': ['f1', 'f2'],
'values': [('a', 'b',), ('c', 'd',)],
}

Where code of Case c returns sql_params_list:

if values.homogenous():
# Case c)
columns = [mi.strip(" `") for mi in match.group("columns").split(",")]
sql_params_list = []
insert_sql_preamble = "INSERT INTO %s (%s) VALUES %s" % (
match.group("table_name"),
match.group("columns"),
values.argv[0],
)
values_pyformat = [str(arg) for arg in values.argv]
rows_list = rows_for_insert_or_update(columns, params, values_pyformat)
insert_sql_preamble = sanitize_literals_for_upload(insert_sql_preamble)
for row in rows_list:
sql_params_list.append((insert_sql_preamble, row))
return {"sql_params_list": sql_params_list}

So it never execute for the homogeneous insert

_execute_insert_homogenous(transaction, parts)

cc:// @larkee @c24t

Metadata

Metadata

Labels

🚨This issue needs some love.api: spannerIssues related to the googleapis/python-spanner API.priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions