aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2024-04-25 13:45:34 +0300
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2024-04-25 13:45:34 +0300
commit7cae6732391f48b7094ff5270b42941bf97c9210 (patch)
tree7baccd6e5756ca6d4b779a9dc67eb473c9915fb0
parent2812e9a904f8367fdb482c09486ca502246e1ed3 (diff)
downloadopenrussian-cli-7cae6732391f48b7094ff5270b42941bf97c9210.tar.gz
use single quotes for SQL string constants consistently
* Double quotes apparently cause problems with newer sqlite versions where they are automatically interpreted as column names. * Should fix lookup of English/German words.
-rwxr-xr-xopenrussian.lua18
1 files changed, 9 insertions, 9 deletions
diff --git a/openrussian.lua b/openrussian.lua
index 9c1df4b..5371024 100755
--- a/openrussian.lua
+++ b/openrussian.lua
@@ -394,22 +394,22 @@ if not verbatim then
-- enough to express "optional brace".
-- We'd probably need regexp for that.
cur = assert(con:execute(string.format([[
- SELECT REPLACE(temp, "'", "") AS completions, words.* FROM words JOIN (
+ SELECT REPLACE(temp, '''', '') AS completions, words.* FROM words JOIN (
-- Search word might be a noun or adjective declension
- SELECT nom||","||gen||","||dat||","||acc||","||inst||","||prep AS temp, word_id
+ SELECT nom||','||gen||','||dat||','||acc||','||inst||','||prep AS temp, word_id
FROM declensions
UNION
-- Search word might be a special adjective inflection
- SELECT comparative||","||superlative||","||
- short_m||","||short_f||","||short_n||","||short_pl AS temp, word_id
+ SELECT comparative||','||superlative||','||
+ short_m||','||short_f||','||short_n||','||short_pl AS temp, word_id
FROM adjectives
UNION
-- Search word might be a verb imperative, past form or conjugation
- SELECT imperative_sg||","||imperative_pl||","||past_m||","||past_f||","||past_n||","||past_pl||
- sg1||","||sg2||","||sg3||","||pl1||","||pl2||","||pl3 AS temp, verbs.word_id
+ SELECT imperative_sg||','||imperative_pl||','||past_m||','||past_f||','||past_n||','||past_pl||
+ sg1||','||sg2||','||sg3||','||pl1||','||pl2||','||pl3 AS temp, verbs.word_id
FROM verbs LEFT JOIN conjugations ON presfut_conj_id = conjugations.id
) ON words.id = word_id
- WHERE LIKELY(disabled = 0) AND ","||completions||"," GLOB '*,%s,*'
+ WHERE LIKELY(disabled = 0) AND ','||completions||',' GLOB '*,%s,*'
ORDER BY rank
]], con:escape(lutf8.gsub(search_word, ACCENT, "")))))
@@ -417,7 +417,7 @@ if not verbatim then
-- It eliminates the concatenations, but has to iterate many tables redundantly.
-- Effectively it is twice as slow as the above query...
cur = assert(con:execute(string.format([[
- SELECT REPLACE(temp, "'", "") AS completions, words.* FROM words JOIN (
+ SELECT REPLACE(temp, '''', '') AS completions, words.* FROM words JOIN (
-- Search word might be a noun or adjective declension
SELECT nom AS temp, word_id FROM declensions
UNION ALL
@@ -510,7 +510,7 @@ if #rows == 0 then
-- be optimized.
-- Perhaps the translations should be in their own (new) indexed table.
cur = assert(con:execute(string.format([[
- SELECT %s(", "||tl||", ") AS completions, words.*
+ SELECT %s(', '||tl||', ') AS completions, words.*
FROM words JOIN translations ON words.id = word_id
WHERE LIKELY(disabled = 0) AND lang = '%s' AND completions GLOB %s('*, %s, *')
ORDER BY rank