Matan Nahmani
Matan Nahmani
Explore posts from servers
DTDrizzle Team
Created by Marcel on 8/17/2024 in #help
[Turso] Undefined primaryKey on push
same here
3 replies
DTDrizzle Team
Created by shikishikichangchang on 6/9/2024 in #help
Turso SQLite vector search
Bump, I made a simple types today but can't get drizzle to use indexing right
4 replies
DTDrizzle Team
Created by philbookst on 12/20/2023 in #help
push:sqlite error _old_push table with turso
@philbookst did you even ran across this error SQL_INPUT_ERROR? when i insert a new column it inserts it but the push just dosen't work well, it keeps throwing error even though it alterd the db
LibsqlError: SQL_INPUT_ERROR: SQL input error: no such column: provider_review_id (at offset 82)
at mapHranaError (file:///home/matan/code/downtoeat/node_modules/@libsql/client/lib-esm/hrana.js:257:16)
at HttpClient.execute (file:///home/matan/code/downtoeat/node_modules/@libsql/client/lib-esm/http.js:53:19)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async TursoSqlite.run (/home/matan/code/downtoeat/node_modules/drizzle-kit/bin.cjs:25414:9)
at async Command.<anonymous> (/home/matan/code/downtoeat/node_modules/drizzle-kit/bin.cjs:63359:9) {
code: 'SQL_INPUT_ERROR',
rawCode: undefined,
[cause]: [ResponseError: SQL input error: no such column: provider_review_id (at offset 82)] {
code: 'SQL_INPUT_ERROR',
proto: {
message: 'SQL input error: no such column: provider_review_id (at offset 82)',
code: 'SQL_INPUT_ERROR'
}
}
}
LibsqlError: SQL_INPUT_ERROR: SQL input error: no such column: provider_review_id (at offset 82)
at mapHranaError (file:///home/matan/code/downtoeat/node_modules/@libsql/client/lib-esm/hrana.js:257:16)
at HttpClient.execute (file:///home/matan/code/downtoeat/node_modules/@libsql/client/lib-esm/http.js:53:19)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async TursoSqlite.run (/home/matan/code/downtoeat/node_modules/drizzle-kit/bin.cjs:25414:9)
at async Command.<anonymous> (/home/matan/code/downtoeat/node_modules/drizzle-kit/bin.cjs:63359:9) {
code: 'SQL_INPUT_ERROR',
rawCode: undefined,
[cause]: [ResponseError: SQL input error: no such column: provider_review_id (at offset 82)] {
code: 'SQL_INPUT_ERROR',
proto: {
message: 'SQL input error: no such column: provider_review_id (at offset 82)',
code: 'SQL_INPUT_ERROR'
}
}
}
6 replies
DTDrizzle Team
Created by philbookst on 12/20/2023 in #help
push:sqlite error _old_push table with turso
any updates?
6 replies
DTDrizzle Team
Created by Matan Nahmani on 10/24/2023 in #help
is there a way to wrap a column select with ST_AsText or any other sql statement?
yes i saw it, problem you can't do it with query so it's kinda annoying
10 replies
DTDrizzle Team
Created by Matan Nahmani on 10/24/2023 in #help
is there a way to wrap a column select with ST_AsText or any other sql statement?
@Angelelz i gave it a try but I think toDriver only happen on executions (insert,update,etc) for query it just uses the default select (select: <column-name>) here is my try:
export type Point = {
lat: number;
lng: number;
};

export const point = customType<{ data: Point; driverData: string }>({
dataType() {
return "POINT";
},
toDriver(value: Point) {
// return sql`POINT(${value.lng}, ${value.lat})`;
return sql`ST_AsText(POINT(${value.lng}, ${value.lat}))`;
},
fromDriver(value: string) {
const matches = value.match(/POINT\((?<lng>[\d.-]+) (?<lat>[\d.-]+)\)/);
const { lat, lng } = matches?.groups ?? {};

if (!matches) {
console.warn(
`Could not parse point value in function pointType.fromDriver`,
value,
);
}

return { lat: parseFloat(String(lat)), lng: parseFloat(String(lng)) };
},
});

const allRooms = async () => {
const rooms = await db.select().from(room).execute();
console.log(db.select().from(room).toSQL());
console.log(rooms);
};
void allRooms();
>>
Query: select `id`, `name`, `image`, `location`, `point`, `code`, `membersLimit`, `currentMembers`, `isAiResponding`, `lastProcessedAt`, `creatorId`, `createdAt` from `room`
Could not parse point value in function pointType.fromDriver kç÷¥áRÀ?á16¨ZD@
Could not parse point value in function pointType.fromDriver Ð|KULRÀ)ÞV$[D@
Could not parse point value in function pointType.fromDriver B#åIRÀydË@ü[D@
{
sql: "select `id`, `name`, `image`, `location`, `point`, `code`, `membersLimit`, `currentMembers`, `isAiResponding`, `lastProcessedAt`, `creatorId`, `createdAt` from `room`",
params: []
}
[
{
id: "8DTNT_tuFtNhbTIze4f7f",
name: "Demo Room",
image: null,
location: "Some location",
point: {
lat: NaN,
lng: NaN
},
...
]
export type Point = {
lat: number;
lng: number;
};

export const point = customType<{ data: Point; driverData: string }>({
dataType() {
return "POINT";
},
toDriver(value: Point) {
// return sql`POINT(${value.lng}, ${value.lat})`;
return sql`ST_AsText(POINT(${value.lng}, ${value.lat}))`;
},
fromDriver(value: string) {
const matches = value.match(/POINT\((?<lng>[\d.-]+) (?<lat>[\d.-]+)\)/);
const { lat, lng } = matches?.groups ?? {};

if (!matches) {
console.warn(
`Could not parse point value in function pointType.fromDriver`,
value,
);
}

return { lat: parseFloat(String(lat)), lng: parseFloat(String(lng)) };
},
});

const allRooms = async () => {
const rooms = await db.select().from(room).execute();
console.log(db.select().from(room).toSQL());
console.log(rooms);
};
void allRooms();
>>
Query: select `id`, `name`, `image`, `location`, `point`, `code`, `membersLimit`, `currentMembers`, `isAiResponding`, `lastProcessedAt`, `creatorId`, `createdAt` from `room`
Could not parse point value in function pointType.fromDriver kç÷¥áRÀ?á16¨ZD@
Could not parse point value in function pointType.fromDriver Ð|KULRÀ)ÞV$[D@
Could not parse point value in function pointType.fromDriver B#åIRÀydË@ü[D@
{
sql: "select `id`, `name`, `image`, `location`, `point`, `code`, `membersLimit`, `currentMembers`, `isAiResponding`, `lastProcessedAt`, `creatorId`, `createdAt` from `room`",
params: []
}
[
{
id: "8DTNT_tuFtNhbTIze4f7f",
name: "Demo Room",
image: null,
location: "Some location",
point: {
lat: NaN,
lng: NaN
},
...
]
10 replies
DTDrizzle Team
Created by Matan Nahmani on 10/24/2023 in #help
is there a way to wrap a column select with ST_AsText or any other sql statement?
@Angelelz you mind giving me a hint over here? this is my custom type: i'm trying the default select of this field to be ST_AsText(<colum-type>) as PointText
export type Point = {
lat: number;
lng: number;
};

export const point = customType<{ data: Point; driverData: string }>({
dataType() {
return "POINT";
},
toDriver(value: Point) {
return sql`POINT(${value.lng}, ${value.lat})`;
},
fromDriver(value: string) {
const matches = value.match(/POINT\((?<lng>[\d.-]+) (?<lat>[\d.-]+)\)/);
const { lat, lng } = matches?.groups ?? {};

if (!matches) {
console.warn(
`Could not parse point value in function pointType.fromDriver`,
value,
);
}

return { lat: parseFloat(String(lat)), lng: parseFloat(String(lng)) };
},
});
export type Point = {
lat: number;
lng: number;
};

export const point = customType<{ data: Point; driverData: string }>({
dataType() {
return "POINT";
},
toDriver(value: Point) {
return sql`POINT(${value.lng}, ${value.lat})`;
},
fromDriver(value: string) {
const matches = value.match(/POINT\((?<lng>[\d.-]+) (?<lat>[\d.-]+)\)/);
const { lat, lng } = matches?.groups ?? {};

if (!matches) {
console.warn(
`Could not parse point value in function pointType.fromDriver`,
value,
);
}

return { lat: parseFloat(String(lat)), lng: parseFloat(String(lng)) };
},
});
10 replies
DTDrizzle Team
Created by msu on 9/8/2023 in #help
Postgres read slaves?
any updates?
16 replies
DTDrizzle Team
Created by Matan Nahmani on 10/3/2023 in #help
createInsertSchema forgets .$type() on text json mode fields in sqlite
p.s i'm not sure if this is even doable 😦
2 replies