mirror of
https://github.com/mdbtools/mdbtools.git
synced 2026-01-02 12:27:09 +08:00
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:
@@ -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; }
|
||||
|
||||
'[^']*'' {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user