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

[BREAKING] Stored procedure/functions support for MsSQL, MySQL and PostrgeSQL #341

Merged
merged 38 commits into from
Apr 29, 2022

Conversation

YauhenPylAurea
Copy link
Contributor

@YauhenPylAurea YauhenPylAurea commented Mar 31, 2022

New section in README.md to show store procedures or user-defined functions, e.g.

Subroutines

Name ReturnType Arguments Type
dbo.get_user @userid int SQL inline table-valued function
dbo.What_DB_is_that @id int SQL Stored Procedure

@@ -28,7 +28,6 @@ db: db_sqlite
usql pg://postgres:pgpass@localhost:55432/testdb?sslmode=disable -f testdata/ddl/postgres95.sql
usql pg://postgres:pgpass@localhost:55413/testdb?sslmode=disable -f testdata/ddl/postgres.sql
usql my://root:mypass@localhost:33306/testdb -f testdata/ddl/mysql56.sql
usql my://root:mypass@localhost:33308/testdb -f testdata/ddl/mysql.sql
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure how to execute such script with stored procedure and function via usql. So it is moved to be executed during container creation

Copy link
Owner

Choose a reason for hiding this comment

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

Does this mean that CREATE PROCEDURE could not be executed using usql ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wasn't able to execute this file with the following code using usql

DELIMITER //
CREATE PROCEDURE GetAllComments()
BEGIN
	SELECT * FROM comments;
END//
DELIMITER ;

Copy link
Owner

@k1LoW k1LoW left a comment

Choose a reason for hiding this comment

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

@YauhenPylAurea GREAT!!!!!!! Thank you!!!

I made a few comments, most of them LTGM.

Let me think about it some more 🙏

Thank you!!!

@@ -467,9 +536,17 @@ func (m *Mssql) Info() (*schema.Driver, error) {
return nil, err
}

dct := dict.New()
dct.Merge(map[string]string{
"Subroutines": "Stored procedures and functions",
Copy link
Owner

Choose a reason for hiding this comment

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

I am wondering if Subroutines is an appropriate name for the section.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point. Should I rename it to ProceduresAndUDF or something like that?

@k1LoW k1LoW force-pushed the main branch 2 times, most recently from 3e3b8b7 to 4cebb4a Compare April 4, 2022 21:52
@@ -487,9 +544,17 @@ func (m *Mysql) Info() (*schema.Driver, error) {
name = "mariadb"
}

dct := dict.New()
dct.Merge(map[string]string{
"Subroutines": "Stored procedures and functions",
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
"Subroutines": "Stored procedures and functions",
"Functions": "Stored procedures and functions",

I've given it a lot of thought.
How about I proceed with the following naming?

Because, the word "Function" is considered to cover the word "Procedure", and the new word "Subroutine" is not used. I tried not to use it.

Copy link
Owner

Choose a reason for hiding this comment

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

I would be happy to have the other "Subroutine" changed as well!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed in 569f959 and 55d046a. Two commits as I have some issues with my WSL (my primary OS is windows, so using WSL to build the product on linux) and there are some issues with it. Thanks!

@@ -67,6 +67,7 @@
"virtual": false
}
],
"subroutines": null,
Copy link
Owner

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed in f0a2289. Is it ok to have empty array?

@@ -459,6 +466,68 @@ ORDER BY i.index_id
return nil
}

const query = `select schema_name(obj.schema_id) as schema_name,
Copy link
Owner

Choose a reason for hiding this comment

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

If you have the extra power, it would be great if you could change the reserved words in the SQL to uppercase.

Copy link
Contributor Author

@YauhenPylAurea YauhenPylAurea Apr 26, 2022

Choose a reason for hiding this comment

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

fixed in e47d996, faa445f, 588ced1 and 7cb71c1

@k1LoW k1LoW added the enhancement New feature or request label Apr 17, 2022
@YauhenPylAurea
Copy link
Contributor Author

updated per the review. Thank you very much to take a look at this PR!

Copy link
Owner

@k1LoW k1LoW left a comment

Choose a reason for hiding this comment

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

GREAT!!!!!!!! Thank you!!!!!!! 🎸

@k1LoW k1LoW merged commit e8b70ce into k1LoW:main Apr 29, 2022
@k1LoW k1LoW changed the title Stored procedure/functions support for MsSQL, MySQL and PostrgeSQL [BREAKING] Stored procedure/functions support for MsSQL, MySQL and PostrgeSQL May 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants