FG
💻 Software🗄️ Databases

[BUG]:drizzle typescript doesn't see boolean column

Fresh5 days ago
Mar 14, 20260 views
Confidence Score57%
57%

Problem

What version of `drizzle-orm` are you using? 0.33.0 What version of `drizzle-kit` are you using? 0.24.2 Describe the Bug i have entity [code block] but when try to update it [code block] see the error: Object literal may only specify known properties, and 'active' does not exist in type '{ createdAt?: SQL<unknown> | Date; country_code?: string | SQL<unknown>; fromIp?: string | SQL<unknown>; toIp?: string | SQL<unknown>; }'.ts(2353) Expected behavior expect that I can to change boolean value and it contains in the `ranges` Environment & setup _No response_

Error Output

error: 
   Object literal may only specify known properties, and 'active' does not exist in type '{ createdAt?: SQL<unknown> | Date; country_code?: string | SQL<unknown>; fromIp?: string | SQL<unknown>; toIp?: s

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix TypeScript Error for Boolean Column in Drizzle ORM

Medium Risk

The TypeScript error occurs because the 'active' property is not defined in the entity schema used by Drizzle ORM. This can happen if the entity definition does not include the 'active' column or if the TypeScript types are not updated to reflect the current database schema.

Awaiting Verification

Be the first to verify this fix

  1. 1

    Update Entity Definition

    Ensure that the 'active' boolean column is included in the entity definition for the relevant table in your Drizzle ORM setup.

    typescript
    const YourEntity = drizzle.define('YourEntity', { createdAt: SQL<Date>, country_code: SQL<string>, fromIp: SQL<string>, toIp: SQL<string>, active: SQL<boolean> });
  2. 2

    Regenerate TypeScript Types

    After updating the entity definition, regenerate the TypeScript types to ensure they reflect the latest schema changes. This can typically be done using the drizzle-kit command.

    bash
    npx drizzle-kit generate
  3. 3

    Check Database Schema

    Verify that the database schema includes the 'active' column in the corresponding table. If it is missing, you may need to run a migration to add it.

    sql
    ALTER TABLE your_table_name ADD COLUMN active BOOLEAN;
  4. 4

    Update TypeScript Code

    Ensure that the TypeScript code where you are trying to update the entity includes the 'active' property in the object literal.

    typescript
    await db.update(YourEntity).set({ active: true }).where({ id: entityId });
  5. 5

    Test the Update Functionality

    Run the application and test the update functionality to confirm that the error no longer occurs and that the 'active' property can be updated successfully.

    typescript
    const result = await db.update(YourEntity).set({ active: false }).where({ id: entityId }); console.log(result);

Validation

Confirm that the TypeScript error no longer appears when updating the entity and that the 'active' property can be successfully updated in the database.

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

drizzleormtypescriptbugpriority