Skip to content

Scripting variables are not expanded in :out and :r commands #522

Description

Hello Everyone,
in mssql-tools a SQL script can use variables even when composing a file path in :out and :r commands.

The go version is not able to expand variables in the filename of these commands:

:on error exit
:setvar WorkingDir ./tmp
:out $(WorkingDir)/file.sql
GO
PRINT '-- Test file.'
GO
:out stdout
GO
:r $(WorkingDir)/file.sql
GO

and leads the SQL script above to the following errors:

Sqlcmd: Error:  Error occurred while opening or operating on file $(WorkingDir)/file.sql (Reason: open $(WorkingDir)/file.sql: no such file or directory).
Sqlcmd: Error:  Error occurred while opening or operating on file $(WorkingDir)/file.sql (Reason: open $(WorkingDir)/file.sql: no such file or directory).

Tested on both v1.5.0 and v1.6.0.

TIA,
Matteo

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions