Class: Fast::SQL::SourceBuffer
- Inherits:
-
Fast::Source::Buffer
- Object
- Fast::Source::Buffer
- Fast::SQL::SourceBuffer
- Defined in:
- lib/fast/sql.rb
Overview
The SQL source buffer is a subclass of Fast::Source::Buffer which contains the tokens of the SQL statement. When you call ast.location.expression it will return a range which is mapped to the tokens. ast = Fast::SQL.parse(“select 1”) ast.location.expression # => #<Fast::Source::Range (sql) 0…9> ast.location.expression.source_buffer.tokens
> [
<PgQuery::ScanToken: start: 0, end: 6, token: :SELECT, keyword_kind: :RESERVED_KEYWORD>,
<PgQuery::ScanToken: start: 7, end: 8, token: :ICONST, keyword_kind: :NO_KEYWORD>]
Instance Attribute Summary
Attributes inherited from Fast::Source::Buffer
Instance Method Summary collapse
Methods inherited from Fast::Source::Buffer
Constructor Details
This class inherits a constructor from Fast::Source::Buffer
Instance Method Details
#tokens ⇒ Object
77 78 79 |
# File 'lib/fast/sql.rb', line 77 def tokens @tokens ||= PgQuery.scan(source).first.tokens end |