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

fix: type generation on load #648

Merged
merged 6 commits into from
Apr 15, 2024
Merged

Conversation

Kevin101Zhang
Copy link
Contributor

@Kevin101Zhang Kevin101Zhang commented Apr 8, 2024

The object post astify() we receive from node-sql-parser changed. We can think about Version Control in the future.
Quick fix here: returning the object to how it was and adding an additional layer on Editor to ensure mounting of types

@Kevin101Zhang Kevin101Zhang linked an issue Apr 8, 2024 that may be closed by this pull request
return isPrimaryKey || isNullable ? false : true;
}

getRequiredStatus(columnDef, nullable) {
const hasDefaultValue =
columnDef.hasOwnProperty("default_val") && columnDef.default_val != null;
Object.prototype.hasOwnProperty.call(columnDef, "default_val") &&
Copy link
Contributor Author

@Kevin101Zhang Kevin101Zhang Apr 8, 2024

Choose a reason for hiding this comment

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

Modified all access methods to avoid shadowing

@Kevin101Zhang Kevin101Zhang marked this pull request as ready for review April 8, 2024 20:16
@Kevin101Zhang Kevin101Zhang requested a review from a team as a code owner April 8, 2024 20:16
@Kevin101Zhang Kevin101Zhang requested a review from darunrs April 8, 2024 20:17
frontend/src/utils/pgSchemaTypeGen.js Outdated Show resolved Hide resolved
frontend/src/utils/pgSchemaTypeGen.js Outdated Show resolved Hide resolved
frontend/src/utils/pgSchemaTypeGen.js Show resolved Hide resolved
frontend/src/utils/pgSchemaTypeGen.js Show resolved Hide resolved
}
}
}
dbSchema[tableName] = columns;
} else if (statement.type === "alter") {
// Process ALTER TABLE statements
let newConstraint = {};
Copy link
Collaborator

Choose a reason for hiding this comment

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

What's the point in moving the contraint variable outside the for loop? It's scope is to apply to the alterSpec in question.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was just due to a stricter eslint configuration where there was a lexical declaration inside a case block. To fix the issue, I moved the lexical declaration outside of the case block.

frontend/src/components/Editor/Editor.jsx Show resolved Hide resolved
@Kevin101Zhang Kevin101Zhang requested review from morgsmccauley and darunrs and removed request for morgsmccauley April 10, 2024 22:59
@Kevin101Zhang
Copy link
Contributor Author

Sorry, let this sit and forgot about rerequesting are review here. Are we good to merge here?

Copy link
Collaborator

@darunrs darunrs left a comment

Choose a reason for hiding this comment

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

LGTM! Just one callout to verify something before merging.

@@ -141,11 +142,11 @@ export class PgSchemaTypeGen {
}

addColumn(columnDef, columns) {
const columnName = columnDef.column.column.expr.value;
const columnName = columnDef.column.column;
Copy link
Collaborator

@darunrs darunrs Apr 15, 2024

Choose a reason for hiding this comment

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

Is this correct? I thought the location of the column name was changed after the update? Can you verify this is the right way to get the name?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep! This should be it! I verified locally with the latest version we have of node-sql-parser and the object we from astify.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

confirmed by pulling and it works for me

@Kevin101Zhang Kevin101Zhang merged commit 1db0cdd into main Apr 15, 2024
@Kevin101Zhang Kevin101Zhang deleted the 629-types-are-not-generated-onload branch April 15, 2024 17:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Types are not generated onLoad
3 participants