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

Negative indentLevel and error with str_repeat #141

Closed
spetters opened this issue Oct 5, 2024 · 4 comments · Fixed by #142
Closed

Negative indentLevel and error with str_repeat #141

spetters opened this issue Oct 5, 2024 · 4 comments · Fixed by #142

Comments

@spetters
Copy link

spetters commented Oct 5, 2024

After updating to 1.5.0 we get an error in the symfony doctrine tab for one of our queries (the query needs to get optimized, i know ;-) ).

str_repeat(): Argument #2 ($times) must be greater than or equal to 0
in vendor/doctrine/sql-formatter/src/SqlFormatter.php (line 77)

Example code (query is not changed):

$sql = 'SELECT u0_.id AS id_0, u0_.revoked_at AS revoked_at_1, u0_.created_at AS created_at_2, u0_.updated_at AS updated_at_3, s1_.id AS id_4, s1_.slug AS slug_5, s1_.description AS description_6, s1_.start AS start_7, s1_.end AS end_8, s1_.slots_min AS slots_min_9, s1_.slots_max AS slots_max_10, s1_.created_at AS created_at_11, s1_.updated_at AS updated_at_12, s2_.id AS id_13, s2_.slug AS slug_14, s2_.position AS position_15, s2_.name AS name_16, s2_.description AS description_17, s2_.intro_time AS intro_time_18, s2_.outro_time AS outro_time_19, s2_.slots_min AS slots_min_20, s2_.slots_max AS slots_max_21, s2_.points AS points_22, s2_.created_at AS created_at_23, s2_.updated_at AS updated_at_24, e3_.id AS id_25, e3_.slug AS slug_26, e3_.name AS name_27, e3_.start AS start_28, e3_.end AS end_29, e3_.registration_deadline AS registration_deadline_30, e3_.subline AS subline_31, e3_.description AS description_32, e3_.code AS code_33, e3_.public AS public_34, e3_.archived AS archived_35, e3_.revoke_time AS revoke_time_36, e3_.image_last_changed AS image_last_changed_37, e3_.settings AS settings_38, e3_.created_at AS created_at_39, e3_.updated_at AS updated_at_40, e3_.image_name AS image_name_41, e3_.image_original_name AS image_original_name_42, e3_.image_mime_type AS image_mime_type_43, e3_.image_size AS image_size_44, e3_.image_dimensions AS image_dimensions_45, u0_.user_id AS user_id_46, u0_.shift_id AS shift_id_47, s1_.station_id AS station_id_48, s2_.event_id AS event_id_49, e3_.owner_id AS owner_id_50, e3_.plan_id AS plan_id_51 FROM user_shift u0_ INNER JOIN shift s1_ ON u0_.shift_id = s1_.id INNER JOIN station s2_ ON s1_.station_id = s2_.id INNER JOIN event e3_ ON s2_.event_id = e3_.id WHERE u0_.user_id = ? AND s1_.start >= ? AND u0_.revoked_at IS NULL ORDER BY s1_.start ASC';
$formatter = new SqlFormatter(null);
$formatter->format($sql);
@greg0ire
Copy link
Member

greg0ire commented Oct 5, 2024

Git says that call was introduced in b2df04b . @mvorisek , can you please take a look?

@mvorisek
Copy link
Contributor

mvorisek commented Oct 5, 2024

I will have a look. I think we need to address #118 properly.

@mvorisek
Copy link
Contributor

mvorisek commented Oct 6, 2024

@greg0ire see #142 fix, b2df04b might introduced this issue, but in general, it was always present - words after "." must be never parsed as such tokens are part of namespaced identifier

@spetters
Copy link
Author

Thank you very much!

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 a pull request may close this issue.

3 participants