From fdfca9e7212eb7a4521ab4517a85964c9c65be29 Mon Sep 17 00:00:00 2001 From: niftynei Date: Mon, 15 Aug 2022 14:38:46 -0500 Subject: [PATCH] sqlite3: no NULLS FIRST 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 --- devtools/sql-rewrite.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/devtools/sql-rewrite.py b/devtools/sql-rewrite.py index 4306d0de1..7ae209403 100755 --- a/devtools/sql-rewrite.py +++ b/devtools/sql-rewrite.py @@ -51,6 +51,8 @@ class Sqlite3Rewriter(Rewriter): 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)