Skip to content

Modal top-level parameter 'close' is a reserved keyword in SQL Server #1070

Description

@charlieglnp

Introduction

The top-level parameter 'close' of the model component is a reserved word in Transect-SQL and results in an error when used on SQL Server.

To Reproduce

select  'modal' as component,
		'test' || 'modal' as id,
		'Close' as close;

The concatenation is to force the query through SQL server (no error occurs otherwise)

Actual behavior

In "test.sql": The following error occurred while executing an SQL statement:
error returned from database: Incorrect syntax near the keyword 'close'.

Expected behavior

Modal component to not return an error when 'close' top-level parameter is used

Version information

  • OS: Windows 11
  • Database SQL Server 2019
  • SQLPage Version 0.38.0

Additional context

A workaround is to enclose the top-level parameter in square brackets

select  'modal' as component,
		'test' || 'modal' as id,
		'Close' as [close];

Activity

  1. lovasoa commented on Oct 28, 2025

    @lovasoa
    Collaborator

    Hi ! Indeed, SQL has a huge number of keywords, so we don't forbid reusing them as component properties.

    You did find the right workaround: quote parameter names when your db does not allow them unquoted.

    We can't remove an existing parameter but we can add aliases. Do you want to make a pull request to sqlpage/templates/modal.handlebars and examples/official-site/sqlpage/migrations/63_modal.sql to add an alias for the "close" parameter ?

  2. charlieglnp commented on Oct 29, 2025

    @charlieglnp
    Author

    Would there be any benefit in SQLPage raising a specific error when a property name is a reserved keyword for the connected database?

    I regularly prototype using sqlite and then deploy onto sql server, or sqlite and then onto mariadb and things like this (as well as not knowing some of the more esoteric keywords!) catch me out.

  3. lovasoa commented on Oct 29, 2025

    @lovasoa
    Collaborator

    That would not be trivial to implement correctly, since sqlpage does not know which keywords are reserved on your database... But if you want to give it a try, you're welcome !

  4. charlieglnp commented on Oct 31, 2025

    @charlieglnp
    Author

    I walked into that one! I can see there might be short cuts for some databases but others eg SQL Server would rely on a static list. It would be a good excuse to contribute so I will have a play and see where I get to, though it will take some time as I'm starting from scratch.

    Aliasing an existing parameter because its a reserved keyword doesn't feel like the right solution to me (I can only see three aliases, one in the form component and two in the chart component?). I think I prefer quoting the parameter when needed, to not break the elegant simplicity of SQLPage, though at the end of the day it's likely to be such an edge case that its not really a big issue at all.

  5. kryskool commented on Nov 7, 2025

    @kryskool
    Contributor

    Hi @charlieglnp

    i made a POC #1088 to use double underscore prefix before the column name, nothing to change on template file.

    Can you test it on SQL Server ?

    regards,

  6. lovasoa commented on Nov 7, 2025

    @lovasoa
    Collaborator

    Is

    select  'modal' as component,
    		'test' || 'modal' as id,
    		'Close' as [close];

    that much worse than

    select  'modal' as component,
    		'test' || 'modal' as id,
    		'Close' as __close;

    ?

    I think 'close' as close_label is both clearer and more immediately useful to all users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions