Skip to content

Conversation

aharpervc
Copy link
Contributor

For example, this now parses appropriately:

create procedure test_proc (a int = 42)
...

Syntax documentation reference: https://learn.microsoft.com/en-us/sql/t-sql/statements/create-procedure-transact-sql?view=sql-server-ver17#e-use-a-procedure-with-wildcard-parameters. This is the syntax used by SQL Server, but I've implemented this as a "normal" Option property of the ProcedureParam struct.

I also added a corresponding common unit test

@aharpervc aharpervc force-pushed the mssql-param-default-value branch 2 times, most recently from f7f6284 to 6e18938 Compare September 19, 2025 21:44
@aharpervc aharpervc marked this pull request as ready for review September 19, 2025 21:48
}

#[test]
fn create_procedure_with_parameter_default_value() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we merge the test into the existing parse_create_procedure_with_parameter_modes? since they cover the same feature

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm, I don't understand. A parameter can be in/out and still have/not have a default, right? Are you suggesting like

pub enum ArgMode {
  In,
  Out,
  InOut,
+ InWithDefault(Expr),
+ OutWithDefault(Expr),
+ InOutWithDefault(Expr),
}

Perhaps I'm not understanding


#[test]
fn create_procedure_with_parameter_default_value() {
let sql = r#"CREATE PROCEDURE test_proc (a INT = 42) AS BEGIN SELECT 1; END"#;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add scenarios demonstrating

  • multiple paramenters having defaults (i.e. (a INT= 42, b INT=43))
  • parameters that include a mode

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done 👍. I've also added an additional unit test for SQL Server, since the parameter identifier syntax is different there.

@aharpervc aharpervc force-pushed the mssql-param-default-value branch from 6e18938 to d05b63c Compare September 26, 2025 15:58
@aharpervc aharpervc force-pushed the mssql-param-default-value branch from d05b63c to 88da3b7 Compare September 26, 2025 15: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.

2 participants