What are the reserved keywords in Elm? - elm

Every once in a while you get a compiler error like this:
It looks like the keyword `port` is being used as a variable.
That's annoying. Is there a complete official list of these keywords? I've gotten as far as finding where the error messages are generated, but I couldn't find where the keywords are actually defined.
Meanwhile, here's a probably incomplete or incorrect list of keywords I found by browsing the syntax page and trying keywords in the repl:
let
in
where
module
exposing
type
port
import
infixr
as
if
else
then

According to the elm-compiler source code the list of reserved keywords is:
keywords =
Set.fromList
[ "if", "then", "else"
, "case", "of"
, "let", "in"
, "type"
, "module", "where"
, "import", "exposing"
, "as"
, "port"
]
Edit:
There are actually some more keywords (found by searching for "reserved" in the repo)
I've found: infix, infixl, infixr. infixr has also be noted by the OP.

Thanks to #oustad (on elmslack), the correct list can be had here and it contains all the reserved words (including where and infix).
module Parse.Primitives.Keyword
( type_, alias_, port_
, if_, then_, else_
, case_, of_
, let_, in_
, infix_, left_, right_, non_
, module_, import_, exposing_, as_, where_, effect_
, command_, subscription_
, jsonTrue, jsonFalse, jsonNull
)

Related

UnhandledPromiseRejectionWarning: RequestError: Incorrect syntax near '17'

Using mssql(6.3.1) and node(14.15.1).
Query works when I use the template literal as shown in the documentation.
This was my query within template literal and it works. (DB names aren't variables here)
await sql.query`
INSERT
INTO
DB.DB.notes (updated_date,
updated_user,
note_description,
work_order_id,
created_date ,
created_user)
values(
${normalizedDate},
${username} ,
${note_description},
${wo_id},
${normalizedDate} ,
${username} )
`;
But when I try to replace the DB with variables let's say ${DB}, it is throwing error.
First it was saying
RequestError: Incorrect syntax near "."
and after that I got
RequestError: Incorrect syntax near "17" (it started from 14 and it's incremented to 17)
This is the documentation, and I have tried a ConnectionPool class, .query('/**query**/'), but none worked for me.
Please suggest what is wrong here.
The syntax you're using in your query generates a parameterised query.
It is not possible to paramaterise "identifiers" in queries. See Can I parameterize the table name in a prepared statement?

Difficulty connecting to REDCap api in Julia

I am trying to use Julia to connect to the REDCap API.
I would like to export a report from a REDCap project as a database.
I keep getting a MethodError that I cannot understand
Here is the code: (I have de-identified the code, however the URL, API_KEY and report_ID are exactly identical to the values I use in the R redcapAPI which works seamlessly)
using REDCap
REDCAP_API = "string of values"
REDCAP_URL = "url"
config_key = REDCap.Config(REDCAP_URL, REDCAP_API, ssl = true)
export_report(config = config_key, report_id = 1000)
I keep getting the following error:
MethodError: no method matching export_report(;
config=REDCap.Config("url", "string of values", true), report_id=1000)
Closest candidates are:
export_report(!Matched::REDCap.Config, !Matched::Any; format,
returnFormat, rawOrLabel, rawOrLabelHeaders, exportCheckboxLabel,
file_loc) at
C:\Users\username\.julia\packages\REDCap\1M6Y9\src\Export.jl:348 got
unsupported keyword arguments "config", "report_id"
top-level scope at none:0
Any help much appreciated
config and report_id are positional rather than named parameters in REDcap.jl. You just need to change it to something like:
export_report(config_key, 1000)

Using reserved word field name in DocumentDB

I inherited a database loaded into DocumentDB, where field name happens to be "Value".
Example of my structure is:
{
...
"Alternates": [
"Type": "ID",
"Value" : "NOCALL"
]
}
when I query (using documentDB's SQL), trying to get back all documents where Alternates.Value = "NOCALL", I get syntax error near
"Value" error
. If I query for Type = "ID", it is all fine.
Seems that the word Value, having a special meaning on DocumentDB is causing an issue.
Putting punctuation (e.g. quotes/double quotes) around "Value" does not seem to help.
Any suggestion on how to resolve this will be much appreciated!
Thank you in advance!
You are correct. Value is a reserved keyword.
To escape this use [""] syntax.
So in your case of
"Alternates": [
"Type": "ID",
"Value" : "NOCALL"
]
SELECT c
FROM c
JOIN alt IN c.Alternates
WHERE alt["Value"] = 'NOCALL'
In my case, the structure looks something like this - { "name": "ABC", "Value": 123 }.
I could escape the reserved keyword using [""] (as answered by others) along with <source_name> i.e.
SELECT c["Value"] FROM c -- 123
Ref.: Querying in Azure Cosmos DB

Replace function error trying to export file with odbc

select id, "last name", "first name", address, "zip code", "Home phone", "Mobile Phone",
REPLACE([email address],',','') as email, "date of birth",
iif ( len([recall date]) = 3,
left("recall date",1)+'/01/20'+ right("recall date",2),
left("recall date",2)+'/01/20'+ right("recall date",2))
as Recalldate
from "patient information"
Im trying to replace a comma that is at the end of each email address somehow its coming from access.
The current query is causing an error
9/18/2014 7:11:01 PM error System.Data.Odbc.OdbcException : ERROR [42000] [Microsoft][ODBC Microsoft Access Driver] Extra ) in query expression '[left([Email address])'.
at System.Data.Odbc.OdbcConnection.HandleError(OdbcHandle hrHandle, RetCode retcode)
at System.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior behavior, String method, Boolean needReader, Object[] methodArguments, SQL_API odbcApiMethod)
at System.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior behavior, String method, Boolean needReader)
at System.Data.Odbc.OdbcCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.Odbc.OdbcCommand.ExecuteReader()
Depending on the provider that you are using for querying the table(s), the functions Replace, IIF, Len, Left and Right might not be available or have different meaning. Without any details on how this query is executed, from where and against with what type of database that you are doing this, it's impossible to tell you what the error might be and how to correct it.
One possibility would be to replace the single quote with double quotes as in:
Replace([email address],",","")
but this is only a guess. You don't seem to have any problem later in your query expression with single quotes; so I don't think that this is the problem in your case. I showing this just to give you an example of what kind of stuff can go wrong when using different providers or different databases.
I've also noticed that sometimes, you use the [...] to delimit your field names and other times, you use the double quotes "...". Not a good ideal to mix this kind of stuff as some providers will accept one notation but not the others.
Finally, by experience, I can tell you that using any space in a field or a table name such as "patient information" is a very, very bad idea. Stop doing that or later, you might deeply regret it when you will query your database from a system that doesn't or badly support that type of stuff.

HTML Local Storage parameter replacement escaping

I'm experimenting with a simple HTML5 local storage based app and I'm having trouble with the parameter replacement escaping (maybe) in my code.
The SQL line I want to execute is:
SELECT name, title FROM testTable WHERE name LIKE '%test%';
so my Javascript line is something like:
tx.executeSql( "SELECT name, title FROM testTable WHERE name LIKE '%?%'", [ search_string ],
This fails (I think) because the ? is being treated as a literal and so the parser complains about too many parameters (search_string).
I optimistically tried using ??? and ["'%", search_string, "%'"] but same result.
Any suggestions - I imagine it's something really obvious so please be gentle.
How about:
tx.executeSql(
"SELECT name, title FROM testTable WHERE name LIKE ?",
[ '%'+search_string+'%' ]
);