question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support for generated columns

See original GitHub issue

This is a fairly new feature – SQLite version 3.31.0 (2020-01-22) – that I, admittedly, haven’t gotten to work yet. But it looks incredibly useful: https://dgl.cx/2020/06/sqlite-json-support

I’m not sure if this is an option on add-column or a separate command like add-generated-column. Either way, it needs an argument to populate it. It could be something like this:

sqlite-utils add-column data.db table-name generated --as 'json_extract(data, "$.field")' --virtual

More here: https://www.sqlite.org/gencol.html

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
simonwcommented, Mar 11, 2022

Two new parameters to .create_table() and friends:

  • generated={...} - generated column definitions
  • generated_stored={...} generated stored column definitions

These columns will be added at the end of the table, but you can use the column_order= parameter to apply a different order.

0reactions
simonwcommented, Mar 11, 2022

Trying to figure out what that extra field in table_info compared to table_xinfo is:

>>> list(db.query("PRAGMA table_xinfo('t')"))
[{'cid': 0,
  'name': 'body',
  'type': 'TEXT',
  'notnull': 0,
  'dflt_value': None,
  'pk': 0,
  'hidden': 0},
 {'cid': 1,
  'name': 'd',
  'type': 'INT',
  'notnull': 0,
  'dflt_value': None,
  'pk': 0,
  'hidden': 2}]
``
Presumably `hidden` 0 v.s 2 v.s. other values has meaning.
Read more comments on GitHub >

github_iconTop Results From Across the Web

13.1.18.7 CREATE TABLE and Generated Columns
CREATE TABLE supports the specification of generated columns. Values of a generated column are computed from an expression included in the column definition ......
Read more >
Rails 7 now introduces support for generated columns with ...
Rails 7 now adds support for generated (virtual) columns to the PostgreSQL adapter that has been available since PSQL v12.
Read more >
Documentation: 15: 5.3. Generated Columns - PostgreSQL
A generated column is a special column that is always computed from other columns. Thus, it is for columns what a view is...
Read more >
Generated (Virtual and Persistent/Stored) Columns - MariaDB
A generated column is a column in a table that cannot explicitly be set to a specific value in a DML query. Instead,...
Read more >
New In PostgreSQL 12: Generated Columns - pgDash
PostgreSQL 12 comes with a new feature called generated columns. Other popular RDBMSes already support generated columns as “computed columns” or “virtual ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found