Skip to content

Commit

Permalink
sqlite3: no NULLS FIRST
Browse files Browse the repository at this point in the history
sqlite3 added NULLS FIRST to their schema as of v3.30.1 but some older
boxes aren't updated (notably the author's own node box).

The default behavior for sqlite3 is to sort nulls first however, this
is *really* only needed for postgres.

As a simple fix (which will allow older boxes to not upgrade their
sqlite yet), simply strip out the NULLS FIRST keywords from sqlite3
queries.

Reported-By: Simon Vrouwe @SimonVrouwe
Fixes: #5517
  • Loading branch information
niftynei committed Aug 16, 2022
1 parent 4e7f89f commit fdfca9e
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions devtools/sql-rewrite.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ def rewrite_single(self, query):
r'decode\((.*),\s*[\'\"]hex[\'\"]\)': 'x\\1',
# GREATEST() of multiple columns is simple MAX in sqlite3.
r'GREATEST\(([^)]*)\)': "MAX(\\1)",
# NULLS FIRST is default behavior on sqlite, make it disappear
r' NULLS FIRST': '',
}
return self.rewrite_types(query, typemapping)

Expand Down

0 comments on commit fdfca9e

Please sign in to comment.