sdispater / orator

The Orator ORM provides a simple yet beautiful ActiveRecord implementation.

Home Page:https://orator-orm.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Union missing *

ajr4me opened this issue · comments

When executing:

first = db.table('whatever').where('id', '<', 10).take(5)
test = db.table('whatever').where('id', '>', 10).take(10).union(first).get()

or

first = WhateverModel.where('id', '<', 10).take(5)
test = WhateverModel.where('id', '>', 10).take(10).union(first).get()

the ORM is generating a wrong query for the second part - there is missing a * after SELECT:

(SELECT * FROM whateverWHEREid> %s LIMIT 10) UNION ALL (SELECT FROMwhateverWHEREid< %s LIMIT 5)

A workaround at the moment would be:

first = db.table('whatever').select('*').where('id', '<', 10).take(5)
test = db.table('whatever').where('id', '>', 10).take(10).union(first).get()