SQLite Forum

Feature Request : Get table name alias from prepared statement
Login
I was working on some tutorial type information for my Sqlite(ODBC)->JS interface node.js addon... So... this is an example application that can benefit from this additional information.


https://github.com/d3x0r/sack.vfs/blob/master/tutorial/tutorial-sqlite.md#sqlite


in the case of name conflicts, the table name results in the query object, rather than just the column name (so one can distinguish one `name` from another `name`)

[Section on overlapped names](https://github.com/d3x0r/sack.vfs/blob/master/tutorial/tutorial-sqlite.md#overlapped-name-behavior)...

```
console.table( db.do( "select fruit.name,color.name from fruit as f \
       join fruit_color fc on fruit_color.fruit_id=fruit.fruit_id \
       join color c on fruit_color.color_id=color.color_id" ) );

┌─────────┬────────────────────┬────────────────────┬──────────────────────────────────────────────────┐
│ (index) │         f          │         c          │                       name                       │
├─────────┼────────────────────┼────────────────────┼──────────────────────────────────────────────────┤
│    0    │ { name: 'apple' }  │  { name: 'red' }   │     [ 'apple', 'red', f: 'apple', c: 'red' ]     │
│    1    │ { name: 'orange' } │ { name: 'orange' } │ [ 'orange', 'orange', f: 'orange', c: 'orange' ] │
│    2    │ { name: 'banana' } │ { name: 'yellow' } │ [ 'banana', 'yellow', f: 'banana', c: 'yellow' ] │
└─────────┴────────────────────┴────────────────────┴──────────────────────────────────────────────────┘
```

And it is handy, if such a query is composed, to be able to rename some other query which uses a different table, but provides an alias for the table name to match what other code expects.

No Parsing required... I know there's some pragma I can issue, but I'm not really in charge of what the application wants to issue for pragmas so that's not really up to me.  They could indeed get back long names and work that way also... but this is just a SQLite ->JS interface, not an ORM.


and mind you this already works as expected through ODBC to MySQL/Postgres/mssql,.... probably mostly everything other than sqlite (as it is)