Skip to content

Commit 63acbc9

Browse files
committed
Update README.md: add Function Naming Rules
1 parent f0affd6 commit 63acbc9

File tree

1 file changed

+35
-4
lines changed

1 file changed

+35
-4
lines changed

README.md

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
- [JavaScript Evaluation](#javascript-evaluation)
1515
- [Examples](#examples)
1616
- [Update Functions](#update-functions)
17+
- [Function Naming Rules](#function-naming-rules)
1718
- [Building from Source](#building-from-source)
1819
- [License](#license)
1920

@@ -63,7 +64,7 @@ SELECT js_create_scalar('function_name', 'function_code');
6364

6465
### Parameters
6566

66-
- **function_name**: The name of your custom function
67+
- **function_name**: The name of your custom function (see [Function Naming Rules](#function-naming-rules))
6768
- **function_code**: JavaScript code that defines your function. Must be in the form `function(args) { /* your code here */ }`
6869

6970
### Example
@@ -97,7 +98,7 @@ SELECT js_create_aggregate('function_name', 'init_code', 'step_code', 'final_cod
9798

9899
### Parameters
99100

100-
- **function_name**: The name of your custom aggregate function
101+
- **function_name**: The name of your custom aggregate function (see [Function Naming Rules](#function-naming-rules))
101102
- **init_code**: JavaScript code that initializes variables for the aggregation
102103
- **step_code**: JavaScript code that processes each row. Must be in the form `function(args) { /* your code here */ }`
103104
- **final_code**: JavaScript code that computes the final result. Must be in the form `function() { /* your code here */ }`
@@ -143,7 +144,7 @@ SELECT js_create_window('function_name', 'init_code', 'step_code', 'final_code',
143144

144145
### Parameters
145146

146-
- **function_name**: The name of your custom window function
147+
- **function_name**: The name of your custom window function (see [Function Naming Rules](#function-naming-rules))
147148
- **init_code**: JavaScript code that initializes variables
148149
- **step_code**: JavaScript code that processes each row. Must be in the form `function(args) { /* your code here */ }`
149150
- **final_code**: JavaScript code that computes the final result. Must be in the form `function() { /* your code here */ }`
@@ -196,7 +197,7 @@ SELECT js_create_collation('collation_name', 'collation_function');
196197

197198
### Parameters
198199

199-
- **collation_name**: The name of your custom collation
200+
- **collation_name**: The name of your custom collation (see [Function Naming Rules](#function-naming-rules))
200201
- **collation_function**: JavaScript code that compares two strings. Must return a negative number if the first string is less than the second, zero if they are equal, or a positive number if the first string is greater than the second.
201202

202203
### Example
@@ -336,6 +337,36 @@ FROM exam_results;
336337

337338
Due to a constraint in [SQLite](https://www3.sqlite.org/src/info/cabab62bc10568d4), it is not possible to update or redefine a user-defined function using the same database connection that was used to initially register it. To modify an existing JavaScript function, the update must be performed through a separate database connection.
338339

340+
## Function Naming Rules
341+
342+
Function names must comply with SQLite identifier rules and must be unique within the database and its schema.
343+
344+
### Unquoted Identifiers
345+
These must follow typical SQL naming conventions:
346+
- Must begin with a letter (A-Z or a-z) or an underscore `_`
347+
- May contain letters, digits (0-9), and underscores `_`
348+
- Are case-insensitive
349+
- Cannot match a reserved keyword unless quoted
350+
351+
**Examples:**
352+
- Valid: `identifier1`, `_temp`, `user_name`
353+
- Invalid: `123abc`, `select`, `identifier-name`
354+
355+
### Quoted Identifiers
356+
SQLite supports delimited identifiers, which allow almost any character, as long as the identifier is properly quoted.
357+
358+
You can use:
359+
- Double quotes: `"identifier name"`
360+
- Square brackets (Microsoft-style): `[identifier name]`
361+
- Backticks (MySQL-style): `` `identifier name` ``
362+
363+
These quoting styles are interchangeable in SQLite. Inside a quoted identifier, you can include:
364+
- Spaces: `"my column"`
365+
- Special characters: `"name@domain"`, `"price€"`, `"weird!name"`
366+
- Reserved SQL keywords: `"select"`, `"group"`
367+
368+
Quoted identifiers are case-sensitive.
369+
339370
## Building from Source
340371

341372
See the included Makefile for building instructions:

0 commit comments

Comments
 (0)