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

feat: SQL module #148

Merged
merged 2 commits into from
Jan 3, 2024
Merged

feat: SQL module #148

merged 2 commits into from
Jan 3, 2024

Conversation

luisdavim
Copy link
Contributor

closes: #145

@luisdavim luisdavim marked this pull request as ready for review December 31, 2023 19:24
@luisdavim
Copy link
Contributor Author

I've also done some refactoring to use object.Errorf instead of object.NewError(fmt.Errorf()) but placed it on a separate commit to make it easier to review.

func (db *DB) Exec(ctx context.Context, args ...object.Object) object.Object {
numArgs := len(args)
if numArgs < 1 {
return object.Errorf("type error: sql.query() requires at least one argument")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
return object.Errorf("type error: sql.query() requires at least one argument")
return object.Errorf("type error: sql.exec() requires at least one argument")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated, thanks.

}

func (db *DB) Inspect() string {
return "sql_conn()"
Copy link
Collaborator

Choose a reason for hiding this comment

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

To match conventions with types defined in other packages it looks like this should be sql.conn. For example in exec the Command type string is exec.command.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated, thanks. I was following the pgx module BTW.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Roger, sounds like I need to update it to match.

"github.com/risor-io/risor/op"
)

const DB_CONN object.Type = "db_conn"
Copy link
Collaborator

Choose a reason for hiding this comment

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

sql.conn? See other comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated, thanks.

Copy link
Collaborator

@myzie myzie left a comment

Choose a reason for hiding this comment

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

This looks really good. Just a couple minor suggestions on the type strings and attr names.

Signed-off-by: Luis Davim <dluis@vmware.com>
@luisdavim
Copy link
Contributor Author

Thanks, I've updated the PR to address your comments.

@myzie myzie merged commit 1c5cf19 into risor-io:main Jan 3, 2024
@luisdavim luisdavim deleted the sql branch January 3, 2024 17:13
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.

Create a more generic SQLmoodule with support for other DB engines
2 participants