Skip to content

Commit 3e54025

Browse files
committed
1 parent f908eab commit 3e54025

2 files changed

Lines changed: 22 additions & 3 deletions

File tree

  • src/main/kotlin/com/github/mgramin/sqlboot

src/main/kotlin/com/github/mgramin/sqlboot/model/resourcetype/impl/composite/md/MarkdownFile.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,13 @@ class MarkdownFile(private val name: String, private val text: String) : File {
4646
override fun content(): ByteArray {
4747
val visitor = CustomVisitor()
4848
Parser.builder().build().parse(text).accept(visitor)
49-
return visitor.getMap().iterator().next().value.toByteArray()
49+
return visitor
50+
.getMap()
51+
.asSequence()
52+
.ifEmpty { mapOf("" to "").asSequence() }
53+
.first()
54+
.value
55+
.toByteArray()
5056
}
5157

5258
@Deprecated("")

src/main/kotlin/com/github/mgramin/sqlboot/sql/select/impl/parser/SELECT.g4

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,29 @@ FUNCTION_EXPRESSION
5353
: ID '(' .*? ')'
5454
;
5555

56+
WITH_EXPRESSION
57+
: 'with' LEFT_BRACKET .*? RIGHT_BRACKET
58+
;
59+
5660

5761

5862

5963

6064
select_statement
61-
: select select_row( COMMA select_row )*
62-
from (schema_name+ DOT)? table_name
65+
: (with)*
66+
select select_row( COMMA select_row )*
67+
from (schema_name+ DOT)? table_name
6368
.*?
6469
;
6570

71+
with
72+
: with_expression
73+
;
74+
75+
with_expression
76+
: 'with' ID 'as' LEFT_BRACKET .*? RIGHT_BRACKET (COMMA ID 'as' LEFT_BRACKET .*? RIGHT_BRACKET)*
77+
;
78+
6679

6780

6881
select

0 commit comments

Comments
 (0)