This is a small niggle, perhaps not worthy of the term "bug".

The Default values when specified in a CREATE TABLE statement will include C-style commented text in the output of the pragma table_info() (or its t.v.f. derivative) while the actual default value handling will parse it out.

Minimal demonstration:

  -- SQLite version 3.24.0  [ Release: 2018-06-04 ]  on SQLitespeed version 2.1.1.16.   -- ================================================================================================

CREATE TABLE t(
  a INTEGER PRIMARY KEY /* This is the PK */,
  b INT DEFAULT 10      /* The Int val   */,
  c TEXT DEFAULT 'Ten'  /* The Text val */
);

INSERT INTO t DEFAULT VALUES;

SELECT * FROM t;

  --       a      |       b      |  c
  -- ------------ | ------------ | ---
  --       1      |      10      | Ten   <-- Correct


PRAGMA table_info(t);

  -- cid | name | type    | notnull | dflt_value                  |  pk
  -- --- | ---- | ------- | ------- | --------------------------- | ---
  --  0  |   a  | INTEGER |    0 |                             |  1
  --  1  |   b  | INT     |    0    | 10      /* The Int val   */ |  0 <--
  --  2  |   c  | TEXT    |    0    | 'Ten'  /* The Text val */   |  0   <-- Not correct


SELECT name, dflt_value FROM pragma_table_info('t');

  -- name | dflt_value
  -- ---- | ---------------------------
  --   a  |
  --   b  | 10      /* The Int val   */  <--
  --   c  | 'Ten'  /* The Text val */    <-- Not correct

DROP TABLE t;

  -- ------------------------------------------------------------------------------------------------

Cheers,
Ryan

_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to