drizzle-team / drizzle-team/drizzle-orm

[BUG]: drizzle-kit pull error when there are comments in a view definition

Open
#5,964 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
TypeScript
Stars
35.8k
Forks
1.6k
Avg merge
2d 7h
Merged PRs (30d)
4

Description

### Report hasn't been filed before.

- [x] I have verified that the bug I'm about to report hasn't been filed before.

### What version of `drizzle-orm` are you using?

1.0.0-rc.4

### What version of `drizzle-kit` are you using?

1.0.0-rc.4

### Other packages

_No response_

### Describe the Bug

I am working in SQL Server.

When there are comments in a view definition,
```
CREATE TABLE [dbo].[Customer]
(
CustomerId INT NOT NULL IDENTITY(1, 1),
CONSTRAINT [PK_Customer_CustomerId] PRIMARY KEY (CustomerId),
Name VARCHAR(50) NOT NULL,
CONSTRAINT [CK_Customer_Name_not_blank_string] CHECK (LEN(Name) > 0)
)

CREATE VIEW dbo.vCustomer WITH SCHEMABINDING AS
/* comment */
SELECT CustomerId,
Name
FROM dbo.Customer
```

If pull(introspect) the existing database

`drizzle-kit pull --init`

returns error

```
Reading config file '/home/user1/gitrepos/my-service/drizzle.config.ts'
[✗] Error during introspection:
Could not process view vCustomer:

CREATE VIEW dbo.vCustomer WITH SCHEMABINDING AS
/* comment */
SELECT CustomerId,
[Name]
FROM dbo.Customer

Error: Could not process view vCustomer:

CREATE VIEW dbo.vCustomer WITH SCHEMABINDING AS
/* comment */
SELECT CustomerId,
[Name]
FROM dbo.Customer

at fromDatabase (/home/user1/gitrepos/my-service/node_modules/drizzle-kit/bin.cjs:157753:35)
at process.processTicksAndRejections (node:internal/process/task_queues:104:5)
at async fromDatabaseForDrizzle (/home/user1/gitrepos/my-service/node_modules/drizzle-kit/bin.cjs:157796:15)
```

If I removed the comment,
```
CREATE VIEW dbo.vCustomer WITH SCHEMABINDING AS
SELECT CustomerId,
Name
FROM dbo.Customer
```

The introspect works fine.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the issue with the shown SQL Server view and `drizzle-kit pull --init`, using the referenced `drizzle.config.ts` setup. Trace the introspection path that processes `vCustomer` and its commented definition; done means views containing comments are introspected successfully without the reported error.

Written by the indexing model from the issue text.

Assessment

Tech stack
sql, typescript
Domain
cli, database
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.