drizzle-orm icon indicating copy to clipboard operation
drizzle-orm copied to clipboard

[BUG]: Introspection Issues with Varchar and Postgis

Open nickreese opened this issue 2 years ago • 3 comments

What version of drizzle-orm are you using?

0.21.1

Describe the Bug

Having issues with introspection. Below are the major issues.

I don't use varchar and def prefer text, but Directus does and the introspection is choking on it.

drizzle-kit: v0.17.0
drizzle-orm: v0.21.1
export const things = pgTable("things", {
	id: serial("id").notNull(),
	status: varchar("status", { length: 255 }).default('draft'::character varying).notNull(),
	userCreated: uuid("user_created"),
	dateCreated: timestamp("date_created", { withTimezone: true, mode: 'string' }),
	userUpdated: uuid("user_updated"),
	dateUpdated: timestamp("date_updated", { withTimezone: true, mode: 'string' }),
	name: varchar("name", { length: 255 }).notNull(),
	slug: varchar("slug", { length: 255 }).default(NULL::character varying),
	// TODO: failed to parse database type 'geometry(Point,4326)'
	coordinates: unknown("coordinates").notNull(),
	type: varchar("type", { length: 255 }).default('unknown'::character varying).notNull(),
},
(table) => {
	return {
		slugUnique: uniqueIndex("parkings_slug_unique").on(table.slug),
	}
});
export const geometryColumns = pgTable("geometry_columns", {
	fTableCatalog: varchar("f_table_catalog", { length: 256 }),
	// TODO: failed to parse database type 'name'
	fTableSchema: unknown("f_table_schema"),
	// TODO: failed to parse database type 'name'
	fTableName: unknown("f_table_name"),
	// TODO: failed to parse database type 'name'
	fGeometryColumn: unknown("f_geometry_column"),
	coordDimension: integer("coord_dimension"),
	srid: integer("srid"),
	type: varchar("type", { length: 30 }),
});

nickreese avatar Mar 07 '23 08:03 nickreese

Just in case you need it... here is how directus sets up defaults... I think it maps down to knex.

    address character varying(255) DEFAULT NULL::character varying,
    url character varying(255) DEFAULT NULL::character varying,

nickreese avatar Mar 07 '23 13:03 nickreese

@nickreese hey, we're preparing something special for Directus internally and I'd love to have a quick chat, show you and collect your feedback, seems like you're an active Directus user

AlexBlokh avatar Mar 08 '23 18:03 AlexBlokh

Can I ask how you recommend dealing with PostGIS columns in general? The unknown column type mentioned above doesn't actually seem to exist when I try to import it ...

jawj avatar Apr 19 '23 22:04 jawj

geometry type was added in [email protected] and [email protected], so should work now as expected

AndriiSherman avatar Jun 02 '24 15:06 AndriiSherman