@anfenn/dync 1.0.20 → 1.0.22

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.
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  SqliteQueryContext,
7
7
  SyncAction,
8
8
  createLocalId
9
- } from "./chunk-I2KQD4DD.js";
9
+ } from "./chunk-YSKDP34Q.js";
10
10
  import "./chunk-SQB6E7V2.js";
11
11
  export {
12
12
  Dync,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Dync
3
- } from "../chunk-I2KQD4DD.js";
3
+ } from "../chunk-YSKDP34Q.js";
4
4
  import "../chunk-SQB6E7V2.js";
5
5
 
6
6
  // src/react/useDync.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anfenn/dync",
3
- "version": "1.0.20",
3
+ "version": "1.0.22",
4
4
  "private": false,
5
5
  "description": "Write once, run IndexedDB & SQLite with sync anywhere - React, React Native, Expo, Capacitor, Electron & Node.js",
6
6
  "keywords": [
@@ -76,7 +76,8 @@ const buildCondition = (condition: SQLiteCondition): BuiltCondition => {
76
76
  switch (condition.type) {
77
77
  case 'equals': {
78
78
  if (condition.caseInsensitive) {
79
- return { clause: `LOWER(${col}) = LOWER(?)`, parameters: [condition.value] };
79
+ // COLLATE NOCASE is more efficient than LOWER() as it can use indexes
80
+ return { clause: `${col} = ? COLLATE NOCASE`, parameters: [condition.value] };
80
81
  }
81
82
  return { clause: `${col} = ?`, parameters: [condition.value] };
82
83
  }
@@ -102,7 +103,7 @@ const buildCondition = (condition: SQLiteCondition): BuiltCondition => {
102
103
  const placeholders = condition.values.map(() => '?').join(', ');
103
104
  if (condition.caseInsensitive) {
104
105
  return {
105
- clause: `LOWER(${col}) IN (${condition.values.map(() => 'LOWER(?)').join(', ')})`,
106
+ clause: `${col} COLLATE NOCASE IN (${placeholders})`,
106
107
  parameters: condition.values,
107
108
  };
108
109
  }
@@ -120,9 +121,12 @@ const buildCondition = (condition: SQLiteCondition): BuiltCondition => {
120
121
 
121
122
  case 'like': {
122
123
  if (condition.caseInsensitive) {
123
- return { clause: `LOWER(${col}) LIKE LOWER(?)`, parameters: [condition.pattern] };
124
+ // LIKE is case-insensitive by default for ASCII in SQLite
125
+ return { clause: `${col} LIKE ?`, parameters: [condition.pattern] };
124
126
  }
125
- return { clause: `${col} LIKE ?`, parameters: [condition.pattern] };
127
+ // GLOB is case-sensitive - convert LIKE wildcards (% *, _ → ?)
128
+ const globPattern = condition.pattern.replace(/%/g, '*').replace(/_/g, '?');
129
+ return { clause: `${col} GLOB ?`, parameters: [globPattern] };
126
130
  }
127
131
  }
128
132
  };