Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: codemirror/lang-sql
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 6.3.3
Choose a base ref
...
head repository: codemirror/lang-sql
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 6.4.0
Choose a head ref
  • 3 commits
  • 5 files changed
  • 2 contributors

Commits on Dec 7, 2022

  1. Fix bracket/brace names in sql.grammar (#12)

    The bracket and brace is switched.
    
    ASCII 91 = "[", which matches "BracketL" at https://github.com/codemirror/lang-sql/blob/main/src/tokens.ts#L25, but was "{" on L45 in sql.grammar
    
    FIX: Fix syntax tree node names for curly and square brackets, which had their names swapped.
    sfc-gh-nchen authored Dec 7, 2022

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    a10023c View commit details

Commits on Jan 23, 2023

  1. Add SQLConfig.schemas

    FEATURE: The new `schemas` config option can be used to provide custom completion objects
    for schema completions.
    
    See https://discuss.codemirror.net/t/lang-sql-oncomplete-custom-database-icon/5441
    marijnh committed Jan 23, 2023
    Copy the full SHA
    e9403c0 View commit details
  2. Mark version 6.4.0

    marijnh committed Jan 23, 2023
    Copy the full SHA
    ea8d12c View commit details
Showing with 23 additions and 8 deletions.
  1. +10 −0 CHANGELOG.md
  2. +1 −1 package.json
  3. +2 −2 src/complete.ts
  4. +4 −4 src/sql.grammar
  5. +6 −1 src/sql.ts
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## 6.4.0 (2023-01-23)

### Bug fixes

Fix syntax tree node names for curly and square brackets, which had their names swapped.

### New features

The new `schemas` config option can be used to provide custom completion objects for schema completions.

## 6.3.3 (2022-11-14)

### Bug fixes
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@codemirror/lang-sql",
"version": "6.3.3",
"version": "6.4.0",
"description": "SQL language support for the CodeMirror code editor",
"scripts": {
"test": "cm-runtests",
4 changes: 2 additions & 2 deletions src/complete.ts
Original file line number Diff line number Diff line change
@@ -107,7 +107,7 @@ class CompletionLevel {
}

export function completeFromSchema(schema: {[table: string]: readonly (string | Completion)[]},
tables?: readonly Completion[],
tables?: readonly Completion[], schemas?: readonly Completion[],
defaultTableName?: string, defaultSchemaName?: string): CompletionSource {
let top = new CompletionLevel
let defaultSchema = top.child(defaultSchemaName || "")
@@ -123,7 +123,7 @@ export function completeFromSchema(schema: {[table: string]: readonly (string |
let schema = top.child(sName)
if (!schema.list.length) schema.list = schema.childCompletions("type")
}
top.list = defaultSchema.list.concat(top.childCompletions("type"))
top.list = defaultSchema.list.concat(schemas || top.childCompletions("type"))

return (context: CompletionContext) => {
let {parents, from, quoted, empty, aliases} = sourceContext(context.state, context.pos)
8 changes: 4 additions & 4 deletions src/sql.grammar
Original file line number Diff line number Diff line change
@@ -40,10 +40,10 @@ element {
Null
ParenL[@name="("]
ParenR[@name=")"]
BraceL[@name="["]
BraceR[@name="]"]
BracketL[@name="{"]
BracketR[@name="}"]
BraceL[@name="{"]
BraceR[@name="}"]
BracketL[@name="["]
BracketR[@name="]"]
Semi[@name=";"]
Dot[@name="."]
Operator
7 changes: 6 additions & 1 deletion src/sql.ts
Original file line number Diff line number Diff line change
@@ -123,6 +123,10 @@ export interface SQLConfig {
/// customize them, you can pass an array of completions through
/// this option.
tables?: readonly Completion[],
/// Similar to `tables`, if you want to provide completion objects
/// for your schemas rather than using the generated ones, pass them
/// here.
schemas?: readonly Completion[],
/// When given, columns from the named table can be completed
/// directly at the top level.
defaultTable?: string,
@@ -149,7 +153,8 @@ export function keywordCompletion(dialect: SQLDialect, upperCase = false): Exten
/// Returns a completion sources that provides schema-based completion
/// for the given configuration.
export function schemaCompletionSource(config: SQLConfig): CompletionSource {
return config.schema ? completeFromSchema(config.schema, config.tables, config.defaultTable, config.defaultSchema)
return config.schema ? completeFromSchema(config.schema, config.tables, config.schemas,
config.defaultTable, config.defaultSchema)
: () => null
}