Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

E0017 value-out-of-range

Literal too long or out of range for the column type.

CodeNameCategoryDefault
E0017value-out-of-rangecorrectnesserror

What it reports

INSERT ... VALUES or UPDATE ... SET gives a column a literal its type can't hold:

  • a string longer than a VARCHAR(n) / CHAR(n) column,
  • an integer outside the range of a SMALLINT / INTEGER / BIGINT column (and MySQL's TINYINT / MEDIUMINT),
  • a number with more integer digits than a NUMERIC(p, s) / DECIMAL(p, s) column allows (p - s).

Example

INSERT INTO orders (user_id, total) VALUES (1, 123456789.50);
error[E0017]: Value 123456789.50 is out of range for column 'orders.total' of type numeric(10,2)
  --> q.sql:1:30
    |
  1 | INSERT INTO orders (user_id, total) VALUES (1, 123456789.50);
    |                              ^^^^^
    = help: Use a value the column type can hold or a wider column type

Fixed:

INSERT INTO orders (user_id, total) VALUES (1, 1234567.50);

Notes

Checked for PostgreSQL, Redshift and MySQL (which rejects these values in its default strict mode); SQLite stores any value. Only literals are checked, and only where they are assigned: WHERE age = 99999 is a valid comparison.

Trailing spaces beyond the length are allowed, as the database truncates them. Numbers with a fraction assigned to an integer column, and numbers with an exponent, are rounded by the database and not checked. MySQL integer columns may be UNSIGNED, so for MySQL a value is only reported when no signed or unsigned column of that size can hold it.

Configuring

# sqlsift.toml
[rules]
value-out-of-range = "warn"   # or "off"

Or for a single line: -- sqlsift:disable E0017. The examples use the schema on the Rules page.