Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion TablePro/Core/Utilities/SQL/QueryClassifier.swift
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ enum QueryClassifier {

/// The first keyword of a code projection, past any opening parentheses.
static func leadingCodeKeyword(_ code: String) -> String {
let remaining = code.drop { $0.isWhitespace || $0 == "(" }
let remaining = code.drop { StatementBlank.isBlank($0) || $0 == "(" }
return remaining.prefix { $0.isLetter || $0.isNumber || $0 == "_" }.uppercased()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,15 @@ struct InvisibleCharacterRemoverTests {

@Test("A PostgreSQL dollar-quoted body is kept")
func dollarQuotedBodyIsKept() {
let text = "SELECT\u{A0}$$a\u{A0}b$$"
#expect(clean(text, grammar: TestGrammar.postgres) == "SELECT $$a\u{A0}b$$")
let text = "SELECT $$a\u{A0}b$$"
#expect(clean(text, grammar: TestGrammar.postgres) == text)
}

/// Measured on PostgreSQL 17: `SELECT<NBSP>$$a b$$` is a syntax error, because every byte over 0x7F continues an
/// identifier there and a `$` glued to one opens no literal. So the text is code, and its blanks are cleaned.
@Test("A dollar sign glued to a non-ASCII blank opens no literal")
func dollarQuoteBehindABlankIsCode() {
#expect(clean("SELECT\u{A0}$$a\u{A0}b$$", grammar: TestGrammar.postgres) == "SELECT $$a b$$")
}

@Test("A MySQL conditional comment runs, so it is cleaned like code")
Expand Down
Loading