Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[BUG]: "Offset is outside the bounds of the DataView" when querying PgGeometry field via RQB relation #2788

Copy link
Copy link
@Sukairo-02

Description

@Sukairo-02
Issue body actions

What version of drizzle-orm are you using?

0.33.0

What version of drizzle-kit are you using?

0.24.0

Describe the Bug

Getting Offset is outside the bounds of the DataView error thrown while querying geometry fields via RQB relations

Expected behavior

Expected to get my data returned and not an error thrown

Environment & setup

Schema:

import { relations } from 'drizzle-orm';
import {
	boolean,
	char,
	date,
	geometry,
	integer,
	pgEnum,
	pgTable,
	serial,
	text,
	timestamp,
	varchar,
	vector,
} from 'drizzle-orm/pg-core';

export const roleEnum = pgEnum('role', ['admin', 'user']);

export const Users = pgTable('users', {
	a: integer('a').array(),
	id: serial('id').primaryKey(),
	name: text('name').notNull(),
	email: text('email'),
	birthdayString: date('birthday_string', { mode: 'string' }),
	birthdayDate: date('birthday_date', { mode: 'date' }),
	createdAt: timestamp('created_at').notNull().defaultNow(),
	role: roleEnum('role'),
	roleText: text('role1', { enum: ['admin', 'user'] }),
	roleText2: text('role2', { enum: ['admin', 'user'] }).default('user'),
	profession: varchar('profession', { length: 20 }),
	initials: char('initials', { length: 2 }),
	isConfirmed: boolean('is_confirmed'),
	vector: vector('vector_column', { dimensions: 5 }),
	geoXy: geometry('geometry_xy', {
		mode: 'xy',
	}),
	geoTuple: geometry('geometry_tuple', {
		mode: 'tuple',
	}),
});

export const Customers = pgTable('customers', {
	id: serial('id').primaryKey(),
	address: text('address').notNull(),
	isConfirmed: boolean('is_confirmed'),
	registrationDate: timestamp('registration_date').notNull().defaultNow(),
	userId: integer('user_id')
		.references(() => Users.id)
		.notNull(),
});

export const Posts = pgTable('posts', {
	id: serial('id').primaryKey(),
	content: text('content'),
	authorId: integer('author_id'),
});

export const usersRelations = relations(Users, ({ one, many }) => ({
	posts: many(Posts),
	customer: one(Customers, {
		fields: [Users.id],
		references: [Customers.userId],
	}),
}));

export const customersRelations = relations(Customers, ({ one, many }) => ({
	user: one(Users, {
		fields: [Customers.userId],
		references: [Users.id],
	}),
	posts: many(Posts),
}));

export const postsRelations = relations(Posts, ({ one }) => ({
	author: one(Users, {
		fields: [Posts.authorId],
		references: [Users.id],
	}),
	customer: one(Customers, {
		fields: [Posts.authorId],
		references: [Customers.userId],
	}),
}));

Database docker image:
joshuasundance/postgis_pgvector

Query:

		await db.query.Posts.findFirst({
			columns: {
				authorId: true,
				content: true,
				id: true,
			},
			with: {
				author: {
					columns: {
						a: true,
						birthdayDate: true,
						birthdayString: true,
						createdAt: true,
						email: true,
						geoTuple: true, // Remove this
						geoXy: true, // and this - then error does not occur
						id: true,
						initials: true,
						isConfirmed: true,
						name: true,
						profession: true,
						role: true,
						roleText: true,
						roleText2: true,
						vector: true,
					},
				},
			},
		});

Full error:

/home/sergey/job/drizzle-graphql/node_modules/.pnpm/drizzle-orm@0.33.0_@libsql+client@0.5.6_@types+pg@8.11.6_mysql2@3.9.7_pg@8.12.0_postgres@3.4.4/node_modules/src/pg-core/columns/postgis_extension/utils.ts:28
        const geomType = view.getUint32(offset, byteOrder === 1);
                              ^


RangeError: Offset is outside the bounds of the DataView
    at DataView.getUint32 (<anonymous>)
    at parseEWKB (/home/sergey/job/drizzle-graphql/node_modules/.pnpm/drizzle-orm@0.33.0_@libsql+client@0.5.6_@types+pg@8.11.6_mysql2@3.9.7_pg@8.12.0_postgres@3.4.4/node_modules/src/pg-core/columns/postgis_extension/utils.ts:28:24)
    at Proxy.mapFromDriverValue (/home/sergey/job/drizzle-graphql/node_modules/.pnpm/drizzle-orm@0.33.0_@libsql+client@0.5.6_@types+pg@8.11.6_mysql2@3.9.7_pg@8.12.0_postgres@3.4.4/node_modules/src/pg-core/columns/postgis_extension/geometry.ts:46:10)
    at mapRelationalRow (/home/sergey/job/drizzle-graphql/node_modules/.pnpm/drizzle-orm@0.33.0_@libsql+client@0.5.6_@types+pg@8.11.6_mysql2@3.9.7_pg@8.12.0_postgres@3.4.4/node_modules/src/relations.ts:713:66)
    at mapRelationalRow (/home/sergey/job/drizzle-graphql/node_modules/.pnpm/drizzle-orm@0.33.0_@libsql+client@0.5.6_@types+pg@8.11.6_mysql2@3.9.7_pg@8.12.0_postgres@3.4.4/node_modules/src/relations.ts:686:9)
    at <anonymous> (/home/sergey/job/drizzle-graphql/node_modules/.pnpm/drizzle-orm@0.33.0_@libsql+client@0.5.6_@types+pg@8.11.6_mysql2@3.9.7_pg@8.12.0_postgres@3.4.4/node_modules/src/pg-core/query-builders/query.ts:101:7)
    at Array.map (<anonymous>)
    at <anonymous> (/home/sergey/job/drizzle-graphql/node_modules/.pnpm/drizzle-orm@0.33.0_@libsql+client@0.5.6_@types+pg@8.11.6_mysql2@3.9.7_pg@8.12.0_postgres@3.4.4/node_modules/src/pg-core/query-builders/query.ts:100:27)
    at <anonymous> (/home/sergey/job/drizzle-graphql/node_modules/.pnpm/drizzle-orm@0.33.0_@libsql+client@0.5.6_@types+pg@8.11.6_mysql2@3.9.7_pg@8.12.0_postgres@3.4.4/node_modules/src/node-postgres/session.ts:77:8)
    at Object.startActiveSpan (/home/sergey/job/drizzle-graphql/node_modules/.pnpm/drizzle-orm@0.33.0_@libsql+client@0.5.6_@types+pg@8.11.6_mysql2@3.9.7_pg@8.12.0_postgres@3.4.4/node_modules/src/tracing.ts:27:11)

Node.js v21.7.1
NicHaley, musaad0, nikolaynizriukhin, Ryanjso, morgan and 7 more

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingSomething isn't workingdb/postgrespriorityWill be worked on nextWill be worked on nextrqbrelational queriesrelational queries

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.