Skip to content

Commit 6f3ad71

Browse files
authored
Merge pull request #25 from sjjian/fix_ident_naming_rule
fix ident naming rule
2 parents 0a4607f + 8ed562d commit 6f3ad71

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

lexer.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,10 @@ func init() {
387387
AddTokenBetween([]byte("--"), []byte("\n"), true, skip)
388388
AddTokenBetween([]byte(`/\*`), []byte("*/"), false, skip)
389389

390-
lexer.Add([]byte("[a-zA-Z]+\\w*"), token(_nonquotedIdentifier))
390+
// see: https://docs.oracle.com/en/database/oracle/oracle-database/12.2/sqlrf/Database-Object-Names-and-Qualifiers.html#GUID-75337742-67FD-4EC0-985F-741C93D918DA
391+
// Non quoted identifiers can only contain alphanumeric characters from your database
392+
// character set and the underscore (_), dollar sign ($), and pound sign (#).
393+
lexer.Add([]byte("[a-zA-Z][A-Za-z0-9_$#]*"), token(_nonquotedIdentifier))
391394

392395
lexer.Add([]byte(`[0-9]+`), func(s *lexmachine.Scanner, m *machines.Match) (interface{}, error) {
393396
v, err := strconv.Atoi(string(m.Bytes))

test/create_table.sql

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,9 @@ k INTEGER,
6666
c CHAR(120) DEFAULT '' NOT NULL,
6767
pad CHAR(60) DEFAULT '' NOT NULL,
6868
PRIMARY KEY (id)
69-
);
69+
);
70+
71+
create table db1.table_1 (id_1 int);
72+
create table db1.table#1 (id#1 int);
73+
create table db1.table$1 (id$1 int);
74+
create table db1.table$#_1 (id$1_ int);

0 commit comments

Comments
 (0)