Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connector - Fix escape note with special characters #639

Merged
merged 3 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ Table "dbo"."StringTypes" {

Table "dbo"."table_with_comments" {
"created_at" datetime2 [default: `getdate()`, note: 'Timestamp when the item was created.']
"description" text [note: 'Detailed description of the item.']
"description" text [note: '''Item\'s description''']
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try something like this:

note: '''Item\'s description for \'mssql\''''

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test added in ef2b37b

"id" int [pk, not null, increment, note: 'Unique identifier for each item.']
"name" varchar [note: 'Name of the item.']
Note: 'This table stores information about various items.'
Expand Down
2 changes: 1 addition & 1 deletion packages/dbml-cli/__test__/db2dbml/mssql/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ GO

EXEC sys.sp_addextendedproperty
@name=N'MS_Description',
@value=N'Detailed description of the item.',
@value=N'Item''s description',
@level0type=N'SCHEMA',
@level0name=N'dbo',
@level1type=N'TABLE',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ Table "default_example" {

Table "hash_index_example" {
"id" int [pk, not null, note: 'unique identifier for each record']
"name" varchar(100) [note: 'first name of the individual']
"name1" varchar(100) [note: 'last name of the individual']
"name" varchar(100) [note: '''first name\'s of the individual''']
"name1" varchar(100) [note: '''last name\'s of the individual''']

Indexes {
(name, name1) [type: hash, name: "idx_name_name1"]
Expand Down
4 changes: 2 additions & 2 deletions packages/dbml-cli/__test__/db2dbml/mysql/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ create unique index idx_email_unique on index_example (email);
-- comments & hash index
create table hash_index_example (
id int primary key comment 'unique identifier for each record',
name varchar(100) comment 'first name of the individual',
name1 varchar(100) comment 'last name of the individual',
name varchar(100) comment 'first name''s of the individual',
name1 varchar(100) comment 'last name''s of the individual',
index idx_name_name1 (name, name1) using hash comment 'hash index for fast lookups on name and name1'
) engine=memory comment='table for storing names with a hash index';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ Table "table2" {

Table "table_with_comments" {
"id" int4 [pk, not null, increment, note: 'Unique identifier for each item.']
"name" varchar(100) [note: 'Name of the item.']
"description" text [note: 'Detailed description of the item.']
"name" varchar(100) [note: '''Item\'s name.''']
"description" text [note: '''Item\'s description''']
"created_at" timestamptz [default: `CURRENT_TIMESTAMP`, note: 'Timestamp when the item was created.']
Note: 'This table stores information about various items.'
}
Expand Down
4 changes: 2 additions & 2 deletions packages/dbml-cli/__test__/db2dbml/postgres/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ CREATE TABLE table_with_comments (
-- Add comments
COMMENT ON TABLE table_with_comments IS 'This table stores information about various items.';
COMMENT ON COLUMN table_with_comments.id IS 'Unique identifier for each item.';
COMMENT ON COLUMN table_with_comments.name IS 'Name of the item.';
COMMENT ON COLUMN table_with_comments.description IS 'Detailed description of the item.';
COMMENT ON COLUMN table_with_comments.name IS 'Item''s name.';
COMMENT ON COLUMN table_with_comments.description IS 'Item''s description';
COMMENT ON COLUMN table_with_comments.created_at IS 'Timestamp when the item was created.';

-- Create Authors table
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1090,7 +1090,7 @@
"not_null": false,
"increment": false,
"note": {
"value": "Detailed description of the item."
"value": "Item's description"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@
"not_null": false,
"increment": false,
"note": {
"value": "first name of the individual"
"value": "first name's of the individual"
}
},
{
Expand All @@ -513,7 +513,7 @@
"not_null": false,
"increment": false,
"note": {
"value": "last name of the individual"
"value": "last name's of the individual"
}
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1007,7 +1007,7 @@
"not_null": false,
"increment": false,
"note": {
"value": "Name of the item."
"value": "Item's name."
}
},
{
Expand All @@ -1020,7 +1020,7 @@
"not_null": false,
"increment": false,
"note": {
"value": "Detailed description of the item."
"value": "Item's description"
}
},
{
Expand Down
Loading