dolthub / go-mysql-server

A MySQL-compatible relational database with a storage agnostic query engine. Implemented in pure Go.
Apache License 2.0
2.32k stars 199 forks source link

Fix error when comparing incompatible types in `IndexLookup`s #2627

Closed jycor closed 1 month ago

jycor commented 1 month ago

When building lookups for IndexedTableAccess, we always convert the key type to the columns type. This is problematic when the key can't be converted to the column type without error.

The expressions used in Filters properly handle this conversion, so we should default to that.

Example:

tmp/main*> create table t (i int primary key);
tmp/main*> select * from t where i = json_array();
error: '[]interface {}' is not a valid value type for 'int'

This doesn't errror in MySQL. Also without a primary key or secondary index, the query succeeds in dolt.