Page 1 of 1
Heredoc delimiters to make embedded strings easier to read
Posted: Fri Jul 13, 2018 10:56 am
by Mistrel
Consider the following SQL statement as we have it now:
Code: Select all
Statement.s=""+
"SELECT"+#CRLF$+
" id, position"+#CRLF$+
"FROM"+#CRLF$+
" location l"+#CRLF$+
"WHERE"+#CRLF$+
" l.id= "+#CRLF$
Compared to if we had heredoc delimiters (in this example '[[' and ']]'):
Code: Select all
Statement.s=[[
SELECT
id, position
FROM
location l
WHERE
l.id=
]]
Re: Heredoc delimiters to make embedded strings easier to re
Posted: Fri Jul 13, 2018 10:57 am
by Cyllceaux
+1
Re: Heredoc delimiters to make embedded strings easier to re
Posted: Fri Jul 13, 2018 11:04 am
by NicTheQuick
btw: You can also use escaped strings for more clarity:
Code: Select all
Statement.s = ~"SELECT\n" +
~" id, position\n" +
~"FROM\n" +
~" location l\n" +
~"WHERE\n" +
~" l.id = \n"
Re: Heredoc delimiters to make embedded strings easier to re
Posted: Fri Jul 13, 2018 11:36 am
by Dude
Users have been requesting block comments for 16 years (
viewtopic.php?f=3&t=2384) and it hasn't happened, so I doubt heredoc delimiters will happen as they're essentially the same concept.
If it helps, you can do it by including text files as strings directly in your source (a "CatchString" for the file), but it means you can't see or edit that text file in your source.
Re: Heredoc delimiters to make embedded strings easier to re
Posted: Fri Jul 13, 2018 2:35 pm
by skywalk
Block comments would help, but SQL is another language and I verify complex queries within SQLite browsers and my database.