Skip to content

fix(models): Prevent trailing newlines in generated SQL queries #112

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

pankaj-bind
Copy link

Screenshot from 2025-06-22 20-34-03

The should query model test case in tests/models/modelsRestApiClient.test.ts was failing due to a strict equality check on the generated SQL query. The actual query contained a trailing newline character that was not present in the expected output.

Root Cause:
The queryModel, batchQueryModel, and finetuneModel methods in src/models/modelsRestApiClient.ts constructed SQL queries by joining an array of clauses with \n. If an optional clause (e.g., the USING or LIMIT clause) was empty, the .join('\n') method would still append a newline separator for that empty item, resulting in an incorrect trailing newline at the end of the final query string.

To fix this, a .filter(Boolean) has been added to the array of clauses in all three affected methods (queryModel, batchQueryModel, and finetuneModel). This removes any empty or falsy strings from the array before they are joined, ensuring that no unnecessary newlines are appended.

npm test -- tests/models/modelsRestApiClient.test.ts

Screenshot from 2025-06-22 20-34-38

This change aligns these methods with the pattern already used in trainModel and retrainModel in the same file, ensuring consistent and correct SQL query generation across the module.

Copy link

Unable to Process PR Review

The author of this PR does not exist on Entelligence Dashboard. Please add the user to Entelligence AI here to enable reviews for this user.

Copy link


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

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.

1 participant