mirror of
https://github.com/lloeki/rebel.git
synced 2025-12-06 10:04:39 +01:00
Add support for DISTINCT
This commit is contained in:
parent
a3712ceefd
commit
adfa38baea
2 changed files with 12 additions and 3 deletions
|
|
@ -13,8 +13,9 @@ module Rebel::SQL
|
|||
exec(Rebel::SQL.drop_table(table_name))
|
||||
end
|
||||
|
||||
def select(*fields, from: nil, where: nil, inner: nil, left: nil, right: nil)
|
||||
def select(*fields, distinct: distinct, from: nil, where: nil, inner: nil, left: nil, right: nil)
|
||||
exec(Rebel::SQL.select(*fields,
|
||||
distinct: distinct,
|
||||
from: from,
|
||||
where: where,
|
||||
inner: inner,
|
||||
|
|
@ -178,9 +179,9 @@ module Rebel::SQL
|
|||
SQL
|
||||
end
|
||||
|
||||
def select(*fields, from: nil, where: nil, inner: nil, left: nil, right: nil)
|
||||
def select(*fields, distinct: nil, from: nil, where: nil, inner: nil, left: nil, right: nil)
|
||||
raw <<-SQL
|
||||
SELECT #{names(*fields)}
|
||||
SELECT #{distinct ? "DISTINCT #{names(*distinct)}" : names(*fields)}
|
||||
#{from?(from)}
|
||||
#{inner?(inner)}
|
||||
#{left?(left)}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue