tursodatabase / tursodatabase/libsql-client-ts

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

Open
#234 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
576
Forks
69
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the two queries using length as the alias in the TypeScript client, then compare their returned rows with the Turso shell behavior described in the issue. Add regression coverage for both count(*) and url cases; done means the client populates length-keyed result objects as it does for the test alias.

Written by the indexing model from the issue text.

Assessment

Tech stack
sqlite, typescript
Domain
api, database
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.