Add backticks around table names in mdb-query output (#307)

* Add [brackets] around mdb-query table names

* Allow column and table names to be in brackets

Column and table names can have whitespace in them.  The traditional way
to indicate that is with bracket characters, like so:
```sql
SELECT [column name] FROM [table name]
```

This change updates the parser to allow bracket format -- similar to
double-quoted format -- in all NAME contexts, i.e., column names, table
names, and database names.

Co-authored-by: Patrick Reynolds <patrick.reynolds@github.com>
This commit is contained in:
Patrick Reynolds
2021-06-02 10:34:35 -04:00
committed by GitHub
parent a31a95056d
commit 246f854b99
2 changed files with 4 additions and 4 deletions

View File

@@ -98,6 +98,8 @@ strptime { return STRPTIME; }
return IDENT;
}
\[[^\]]+\] { yylval->name = g_strndup(yytext+1, yyleng-2); return NAME; }
[a-z\xa0-\xff][a-z0-9_#@\xa0-\xff]* { yylval->name = g_strdup(yytext); return NAME; }
'[^']*'' {

View File

@@ -182,12 +182,10 @@ int main (int argc, char **argv) {
}
break;
case 5: // table name
if(strcmp(sql_tables,"") == 0) {
strcpy(sql_tables,name1);
} else {
if(strcmp(sql_tables,"") != 0) {
strcat(sql_tables,",");
strcat(sql_tables,name1);
}
sprintf(sql_tables+strlen(sql_tables),"[%s]",name1);
break;
case 6: // column name
if(strcmp(sql_columns,"") == 0) {