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

NamedQuery processes parameter names within comment blocks. #894

Open
ocket8888 opened this issue Sep 14, 2023 · 0 comments
Open

NamedQuery processes parameter names within comment blocks. #894

ocket8888 opened this issue Sep 14, 2023 · 0 comments

Comments

@ocket8888
Copy link

In my project, my files all need to have Apache-2.0 license headers if possible. This is done with a comment block. My SQL queries are in separate files and then embedded like

//go:embed select.sql
var selectQuery string

and then the select query file looks like

-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at

-- 	http://www.apache.org/licenses/LICENSE-2.0

-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.

SELECT * FROM my_table

Notice the URL. If you try to run this with a NamedQuery, it'll tell you that it cannot find the parameter with the name "", because it's trying to replace the : from the license URL.

Comment blocks should not be processed for any kind of parameter replacement.

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

No branches or pull requests

1 participant