Open stepantubanov opened 5 months ago
In a select with multiple from, index hint is simply placed after the last one which produces incorrect SQL.
from
fn main() { let sql = Query::select() .column(Asterisk) .from(Alias::new("a")) .force_index(IndexName::new("idx_a"), IndexHintScope::All) .from(Alias::new("b")) .force_index(IndexName::new("idx_b"), IndexHintScope::All) .to_string(MysqlQueryBuilder); println!("{sql}"); }
Correct SQL would be
SELECT * FROM `a` FORCE INDEX (`idx_a`), `b` FORCE INDEX (`idx_b`)
Actual generated SQL:
SELECT * FROM `a`, `b` FORCE INDEX (`idx_a`) FORCE INDEX (`idx_b`)
Which results in an error: Key 'idx_a' doesn't exist in table 'b'
Key 'idx_a' doesn't exist in table 'b'
Always
sea-query 0.30.7
Description
In a select with multiple
from
, index hint is simply placed after the last one which produces incorrect SQL.Steps to Reproduce
Expected Behavior
Correct SQL would be
Actual Behavior
Actual generated SQL:
Which results in an error:
Key 'idx_a' doesn't exist in table 'b'
Reproduces How Often
Always
Versions
sea-query 0.30.7