libsql-client-ts icon indicating copy to clipboard operation
libsql-client-ts copied to clipboard

'length' keyword is not supported as an alias name on the client

Open giovannibenussi opened this issue 1 year ago • 0 comments

As mentioned in this discord thread, using length as an alias name doesn't return any results:

// query: select count(*) as 'length' from my_table
ResultSetImpl {
  columns: [ "length" ],
  columnTypes: [ "" ],
  rows: [ {} ],
  rowsAffected: 0,
  lastInsertRowid: undefined
}

// query: select url as 'length' from my_table
ResultSetImpl {
  columns: [ "length" ],
  columnTypes: [ "TEXT" ],
  rows: [ {}, {} ],
  rowsAffected: 0,
  lastInsertRowid: undefined
}

However, the code works when using an alias name other than length:

// query: select count(*) as 'test' from my_table
ResultSetImpl {
  columns: [ "test" ],
  columnTypes: [ "" ],
  rows: [ { test: 2 } ],
  rowsAffected: 0,
  lastInsertRowid: undefined
}

// query: select url as 'test' from my_table
ResultSetImpl {
  columns: [ "test" ],
  columnTypes: [ "TEXT" ],
  rows: [ { test: "https://example.com" }, { test: "https://example.org" } ],
  rowsAffected: 0,
  lastInsertRowid: undefined
}

Using the length name as an alias works on the Turso shell.

giovannibenussi avatar Jul 01 '24 04:07 giovannibenussi