Skip to content

Commit cf0be59

Browse files
committed
allow underscore in identifier start
closes #20
1 parent 8ffe269 commit cf0be59

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

lib/lexer.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ defmodule SQL.Lexer do
133133
def lex(<<b, _::binary>>=rest, file, params, binding, aliases, line, column, type, data, meta, acc, n) when is_dot(b) do
134134
update_state(rest, file, params, binding, aliases, line, column, type, data, meta, acc, n, line, column, nil, [], nil)
135135
end
136-
def lex(<<b, rest::binary>>, file, params, binding, aliases, line, column, type, data, meta, acc, n) when type != :ident and Unicode.Set.match?(b, "[[:Lu:], [:Ll:], [:Lt:], [:Lm:], [:Lo:], [:Nl:]]") do
136+
def lex(<<b, rest::binary>>, file, params, binding, aliases, line, column, type, data, meta, acc, n) when type != :ident and (Unicode.Set.match?(b, "[[:Lu:], [:Ll:], [:Lt:], [:Lm:], [:Lo:], [:Nl:]]") or b == ?_) do
137137
update_state(rest, file, params, binding, aliases, line, column, type, data, meta, acc, n, line, column+1, :ident, [[]|[b]], meta)
138138
end
139139
def lex(<<b, rest::binary>>, file, params, binding, aliases, line, column, :ident=type, data, meta, acc, n) when Unicode.Set.match?(b, "[[:Mn:], [:Mc:], [:Nd:], [:Pc:], [:Cf:]]") do

test/adapters/postgres_test.exs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ defmodule SQL.Adapters.PostgresTest do
175175
assert "select db.users.id" == to_string(~SQL[select db.users.id])
176176
assert "select db.users" == to_string(~SQL[select db.users])
177177
assert "select db" == to_string(~SQL[select db])
178+
assert "select _id" == to_string(~SQL[select _id])
178179
end
179180

180181
test "qouted" do

0 commit comments

Comments
 (0)