dirsql 0.3.114 → 0.3.116

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,103 @@
1
+ # Path-tables
2
+
3
+ A **path-table** is a table you never declare. Write a path where a table name
4
+ goes, and dirsql scans the filesystem for you:
5
+
6
+ ```sql
7
+ SELECT basename, size FROM './' ORDER BY size DESC LIMIT 5;
8
+ ```
9
+
10
+ No `.dirsql.toml` entry, no DDL, no `on_file`. The name *is* the query.
11
+
12
+ ## How resolution works
13
+
14
+ dirsql never parses your SQL. It hands the statement to SQLite untouched; only
15
+ when SQLite reports `no such table: X` does dirsql look at `X`:
16
+
17
+ 1. If `X` starts with `./`, dirsql registers a path-table over the matching
18
+ files and re-prepares the statement.
19
+ 2. Otherwise the SQLite error stands, unchanged.
20
+
21
+ Because discovery rides on SQLite's own errors, joins, subqueries and CTEs work
22
+ with no extra machinery — SQLite names each missing target in turn, and dirsql
23
+ resolves them one at a time.
24
+
25
+ Two consequences follow directly:
26
+
27
+ - **A declared table always wins.** The fallback only runs after SQLite has
28
+ already failed to find the name, so a real table is found first. A table you
29
+ genuinely named `"./"` shadows the path, and dirsql will not argue.
30
+ - **A typo stays a typo.** `SELECT * FROM usrs` fails with SQLite's error and
31
+ nothing else. dirsql never guesses that an ordinary identifier meant a file.
32
+
33
+ ## Writing the path
34
+
35
+ The path is relative to the **index root** — the directory dirsql is indexing,
36
+ not your shell's working directory.
37
+
38
+ | You write | dirsql scans |
39
+ | --- | --- |
40
+ | `'./'` | every file under the index root, recursively |
41
+ | `'./docs/*.md'` | markdown files directly inside `docs/` |
42
+ | `'./docs/**/*.md'` | markdown files at any depth under `docs/` |
43
+
44
+ The `./` is required. A bare glob is rejected with a hint rather than silently
45
+ accepted:
46
+
47
+ ```
48
+ SELECT * FROM '**/*.md';
49
+ -- no such table: **/*.md; did you mean './**/*.md'?
50
+ ```
51
+
52
+ Absolute (`/var/log/*.log`), parent-relative (`../notes`) and home-relative
53
+ (`~/notes`) path-tables are recognized but not yet resolved; they report that
54
+ they are unsupported rather than returning wrong rows.
55
+
56
+ ## Columns
57
+
58
+ A path-table has the same [virtual columns](/reference/columns) as any dirsql
59
+ table:
60
+
61
+ | Column | Type | Meaning |
62
+ | --- | --- | --- |
63
+ | `path` | TEXT | path relative to the index root |
64
+ | `basename` | TEXT | filename with extension |
65
+ | `dir` | TEXT | parent directory, relative to the index root |
66
+ | `ext` | TEXT | extension without the dot |
67
+ | `size` | INTEGER | size in bytes |
68
+ | `mtime` | INTEGER | modification time, Unix seconds |
69
+ | `ctime` | INTEGER | creation/change time, Unix seconds |
70
+
71
+ There is also a hidden `content` column holding the file's text. It is excluded
72
+ from `SELECT *` and read only when you name it, so scanning a large tree costs
73
+ nothing until you ask for file bodies:
74
+
75
+ ```sql
76
+ SELECT path FROM './docs/*.md' WHERE content LIKE '%deprecated%';
77
+ ```
78
+
79
+ A file that cannot be read, or is not valid UTF-8, yields `NULL` content rather
80
+ than failing the query.
81
+
82
+ ## Freshness and scope
83
+
84
+ A path-table is scanned when the statement runs, so it always reflects the
85
+ filesystem as it is *now* — unlike declared tables, which are indexed on build
86
+ and updated by the watcher. A file created a moment ago shows up immediately.
87
+
88
+ Path-tables are per-connection and are never written to a persistent cache, so
89
+ they cannot leak into `sqlite_master` or survive a restart. The reserved
90
+ top-level `.dirsql/` directory is excluded from the scan, as everywhere else.
91
+
92
+ ## Joining against declared tables
93
+
94
+ Path-tables are ordinary SQLite tables once resolved, so they join freely:
95
+
96
+ ```sql
97
+ SELECT p.basename, f.size
98
+ FROM './docs/*.md' AS p
99
+ JOIN files AS f ON f.path = p.path;
100
+ ```
101
+
102
+ A zero-match path-table is not an error — it is an empty table, and the query
103
+ returns no rows.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dirsql",
3
- "version": "0.3.114",
3
+ "version": "0.3.116",
4
4
  "description": "Ephemeral SQL index over a local directory",
5
5
  "license": "MIT",
6
6
  "repository": "https://github.com/thekevinscott/dirsql",
@@ -212,15 +212,15 @@
212
212
  ]
213
213
  },
214
214
  "optionalDependencies": {
215
- "@dirsql/lib-linux-x64-gnu": "0.3.114",
216
- "@dirsql/lib-linux-arm64-gnu": "0.3.114",
217
- "@dirsql/lib-darwin-x64": "0.3.114",
218
- "@dirsql/lib-darwin-arm64": "0.3.114",
219
- "@dirsql/lib-win32-x64-msvc": "0.3.114",
220
- "@dirsql/cli-linux-x64-gnu": "0.3.114",
221
- "@dirsql/cli-linux-arm64-gnu": "0.3.114",
222
- "@dirsql/cli-darwin-x64": "0.3.114",
223
- "@dirsql/cli-darwin-arm64": "0.3.114",
224
- "@dirsql/cli-win32-x64-msvc": "0.3.114"
215
+ "@dirsql/lib-linux-x64-gnu": "0.3.116",
216
+ "@dirsql/lib-linux-arm64-gnu": "0.3.116",
217
+ "@dirsql/lib-darwin-x64": "0.3.116",
218
+ "@dirsql/lib-darwin-arm64": "0.3.116",
219
+ "@dirsql/lib-win32-x64-msvc": "0.3.116",
220
+ "@dirsql/cli-linux-x64-gnu": "0.3.116",
221
+ "@dirsql/cli-linux-arm64-gnu": "0.3.116",
222
+ "@dirsql/cli-darwin-x64": "0.3.116",
223
+ "@dirsql/cli-darwin-arm64": "0.3.116",
224
+ "@dirsql/cli-win32-x64-msvc": "0.3.116"
225
225
  }
226
226
  }