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

Ignoring errors and continue on sql generate #1756

Closed
SebastienMelki opened this issue Jul 23, 2022 · 2 comments
Closed

Ignoring errors and continue on sql generate #1756

SebastienMelki opened this issue Jul 23, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@SebastienMelki
Copy link

SebastienMelki commented Jul 23, 2022

What do you want to change?

Hello,

I have multiple directories that contain .sql files that I would like sqlc to generate code from. Most of these files are "create table" files, but some of them are "create procedures" or "triggers". Sqlc errors out on those files when generating. I would like to be able to still get the generated code from the proper create table files. Is there a way to let 'sqlc generate' ignore errors and still generate the proper files that contain valid create table statements?

Thanks!
image

What database engines need to be changed?

MySQL

What programming language backends need to be changed?

Go

@SebastienMelki SebastienMelki added enhancement New feature or request triage New issues that hasn't been reviewed labels Jul 23, 2022
@kyleconroy kyleconroy removed the triage New issues that hasn't been reviewed label Jul 27, 2022
@kyleconroy
Copy link
Collaborator

Is there a way to let 'sqlc generate' ignore errors and still generate the proper files that contain valid create table statements?

There currently isn't. The easiest workaround is to create a different folder with only the create table SQL files. Can you include some of the SQL files that are causing errors? It may be possible to successfully parse them.

@Gobd
Copy link

Gobd commented Mar 23, 2023

I'm having what is probably the same exact issue. I cloned our DB repos in an attempt to use sqlc (we also use skeema as did the poster). The files that are throwing errors are like this and throwing the same error as the poster: syntax error near "DELIMITER //".

DELIMITER //
CREATE DEFINER=`lamaster`@`%` PROCEDURE `activate_existing_crons`(IN var_cron_id INT)
BEGIN
        UPDATE `liveauct_crons`.`master_crons` SET active = 1 WHERE cron_id = var_cron_id;
    END//
DELIMITER ;

I have fixed this myself with a bash script to my liking. It just deletes the bad files since sqlc doesn't need them. Although maybe it would need them if I tried writing a query that called the functions they defined.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants