-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat: add prism parser #114
Conversation
cb7e6da
to
e3b4857
Compare
private extractTableName(argNodes: Node[]): string { | ||
const nameNode = argNodes.find((node) => node instanceof StringNode) | ||
// @ts-ignore: unescaped is defined as string but it is actually object | ||
return (nameNode as StringNode).unescaped.value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unescaped
is defined as string but it is actually object.
We might need to fix ruby/prism package. btw, let me use ts-ignore
in this pr.
StringNode {
nodeID: 3,
location: { startOffset: 22, length: 7 },
openingLoc: { startOffset: 22, length: 1 },
contentLoc: { startOffset: 23, length: 5 },
closingLoc: { startOffset: 28, length: 1 },
unescaped: { encoding: 'utf-8', validEncoding: true, value: 'users' }
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I commented lightly!
import { processor as schemarbProcessor } from './schemarb/index.js' | ||
import { processor as postgresqlProcessor } from './sql/index.js' | ||
|
||
type SupportedFormat = 'schemarb' | 'postgres' | ||
type SupportedFormat = 'schemarb' | 'postgres' | 'schemarb-prism' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the default should be prism, how about the following?
type SupportedFormat = 'schemarb' | 'postgres' | 'schemarb-prism' | |
type SupportedFormat = 'schemarb' | 'postgres' | 'schemarb-deprecated-pegjs' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd be fine with a renaming with a different PR 👍🏻
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll replace them in another pr 👍
The conversion part of AST will be checked in an hour 🙏🏻 |
d755752
to
b64136d
Compare
@MH4GF |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
Nice work!!!
}) | ||
|
||
expect(result).toEqual(expected) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice test 😄
// Since 5.1 PostgreSQL adapter uses bigserial type for primary key in default | ||
// See:https://github.com/rails/rails/blob/v8.0.0/activerecord/lib/active_record/migration/compatibility.rb#L377 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an awesome comment!
frontend/packages/db-structure/src/parser/schemarb-prism/parser.ts
Outdated
Show resolved
Hide resolved
@MH4GF @hoshinotsuyoshi @FunamaYukina If anyone has idea, please let me know 🙏
|
It seems to be a pattern that works well during development but causes problems after build. Perhaps it is necessary to make this an absolute reference with |
cdb458b
to
5f6d3ef
Compare
@sasamuku Maybe this is why it's in devDependencies? 💭
|
@MH4GF Then, another error happened...
This is similar to error on #90 maybe.
|
cb22cf9
to
e0a271c
Compare
@sasamuku Oh, Perhaps this fix is needed: https://github.com/ruby/prism/blob/main/docs/javascript.md#browser One could view it as a bad idea to include it in the build for browsers since this time it is running in the CLI, but it should be better to be able to run it in both. |
"@liam/ui": "workspace:*", | ||
"@xyflow/react": "12.3.5", | ||
"react": "18" | ||
}, | ||
"devDependencies": { | ||
"@biomejs/biome": "1.9.3", | ||
"@liam/configs": "workspace:*", | ||
"@liam/db-structure": "workspace:*", | ||
"@liam/ui": "workspace:*", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
( Oh, sorry, but I wonder why the CI results for #108 show success. 💭 )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔💭
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I apologize for the delay in the review🙇♀️. I've checked the parsing process and it looks good to me (LGTM). I think we can skip the smoke test portion for now and address it in a separate issue.💭
It seems like there's a WASI-related error...
Some results of running pnpm dev
[plugin:vite:resolve] [plugin vite:resolve] Module "wasi" has been externalized for browser compatibility
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps this fix is needed:
https://github.com/ruby/prism/blob/main/docs/javascript.md#browser
I see, I understand that this is the issue with frontend-ci. I didn’t notice anything else concerning in the implementation!
@@ -1,4 +1,3 @@ | |||
export { parse } from './parser/index.js' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aef7680
to
94f3c88
Compare
94f3c88
to
a95ab54
Compare
// NOTE: suppress the following warning: | ||
if (!stderr.includes('ExperimentalWarning: WASI is an experimental feature and might change at any time')) { | ||
expect(stderr).toBe('') | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Workaround for WASI warning.
We could disable warning on npx command, but it would be better to suppress in case of only this waring.
ac65c05
to
e6996b8
Compare
Summary
Add prism parser for schema.rb.
This is alternative to pegjs.
vs pegjs
Related Issue
Changes
Testing
Other Information