FirebirdSQL / firebird

Firebird server, client and tools
https://www.firebirdsql.org/
1.25k stars 215 forks source link

LIST(column, delimiter_expr) should require any column references in delimiter_expr be in ithe GROUP-BY clause [CORE2443] #2857

Open firebird-automations opened 15 years ago

firebird-automations commented 15 years ago

Submitted by: Cosmin Apreutesei (cosmin_ap2)

test case:

select list(t.x, t.d) from ( select 'a' as x, ',' as d from rdb$database union all select 'b' as x, '.' as d from rdb$database union all select 'c' as x, ';' as d from rdb$database ) t

firebird-automations commented 15 years ago

Commented by: Sean Leyne (seanleyne)

1 - since the LIST() syntax defines a delimiter_expr, I don't think that using a column falls into that syntax

2 - This is not what the LIST() is about, the delimiter_expr is a constant!!

firebird-automations commented 15 years ago

Commented by: @dyemanov

Sean, you're wrong here. Starting with v2.5, LIST() is intended to support not only constants but virtually everything as its last argument. delimited_expr means a value expression and column is a perfectly valid expression (at least from the standard POV).

firebird-automations commented 15 years ago

Commented by: Sérgio Alexandre Gianezini Júnior (sergioalexandre)

So, currently (2.1.3), List() can do something like this? Or will be only avaiable at 2.5+ versions?

Select CustomerCountry, List(CustomerName, Ascii_Char(13) || Ascii_Char(10)) CustomerList From Customers Group By CustomerCountry

I know that I can use this until 2.1.2 List(CustomerName || Ascii_Char(13) || Ascii_Char(10), '') CustomerList

But I get a extra carriage+linefeed at end of list...

firebird-automations commented 14 years ago

Commented by: @asfernandes

Can't we consider the behaviour expected?

The delimiter is got from current record before concatenation of each expression.