From dda13b3c9778b65717abb6f9a58af8dea40c8f00 Mon Sep 17 00:00:00 2001 From: Erica Fischer Date: Fri, 3 Jan 2025 10:26:54 -0800 Subject: [PATCH] Case smashing and prefix trimming in the select --- tile-join.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tile-join.cpp b/tile-join.cpp index 8304ec0f..a9b2eea7 100644 --- a/tile-join.cpp +++ b/tile-join.cpp @@ -83,8 +83,10 @@ std::vector> get_joined_rows(sqlite3 *db, const ret.resize(join_keys.size()); // double quotes for table and column identifiers - const char *s = sqlite3_mprintf("select \"%w\", * from \"%w\" where \"%w\" in (", - join_table_column.c_str(), join_table.c_str(), join_table_column.c_str()); + const char *s = sqlite3_mprintf("select LOWER(LTRIM(SUBSTR(\"%w\",1,LENGTH(\"%w\")-3),'0')||SUBSTR(\"%w\",-3,3)), * from \"%w\" where LOWER(LTRIM(SUBSTR(\"%w\",1,LENGTH(\"%w\")-3),'0')||SUBSTR(\"%w\",-3,3)) in (", + join_table_column.c_str(), join_table_column.c_str(), join_table_column.c_str(), + join_table.c_str(), + join_table_column.c_str(), join_table_column.c_str(), join_table_column.c_str()); std::string query = s; sqlite3_free((void *) s);