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

Fixed MySQL Queries #1

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

Conversation

sananguliyev
Copy link

There are some issues with queries:

  1. TEXT column can't have a default value (related to sshkeys & custattr from users table)
  2. GROUPS is a reserved word in MySQL, which means we either rename the table or use between backticks (I have used backticks in order to not change any implementation)

@42wim
Copy link

42wim commented Feb 5, 2023

You can have a default though, fixed by putting it in () custattr TEXT DEFAULT ('{}')) (https://www.drupal.org/project/drupal/issues/3232804)

@sananguliyev
Copy link
Author

@42wim actually you're right. I missed that. It's also possible to use that.

@42wim
Copy link

42wim commented Feb 5, 2023

I've found some other issues now btw while testing the mysql backend.
All the code where groups don't have the backticks fail, so they need also be changed

https://github.com/glauth/glauth/blob/0e7769ff841e096dbf0cb67768cbd2ab7142f6fb/v2/pkg/plugins/basesqlhandler.go#L186-L187

err = h.database.cnx.QueryRow(fmt.Sprintf(`
			SELECT g.gidnumber FROM groups g WHERE lower(name)=%s`, h.sqlBackend.GetPrepareSymbol()), groupName).Scan(

needs to become

err = h.database.cnx.QueryRow(fmt.Sprintf(`
			SELECT g.gidnumber FROM `+"`groups`"+` g WHERE lower(name)=%s`, h.sqlBackend.GetPrepareSymbol()), groupName).Scan(

I'm not sure if this has impact on postgres/sqlite

@Fusion
Copy link
Contributor

Fusion commented Feb 5, 2023

Backticks may indeed causes in postgres. I'm going to check that out, good catch!

@sananguliyev
Copy link
Author

Any update here?

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.

3 participants