Skip to content

Add gorm dialect for db_pem_storer#92

Merged
zachmann merged 4 commits into
go-oidfed:mainfrom
waldofouche:feature/add-gorm-dilect-for-mysql
Jun 10, 2026
Merged

Add gorm dialect for db_pem_storer#92
zachmann merged 4 commits into
go-oidfed:mainfrom
waldofouche:feature/add-gorm-dilect-for-mysql

Conversation

@waldofouche

Copy link
Copy Markdown
Contributor

Solves #83 (comment)

Adds a new GormDBDataType selector to swap the schema for DB based pems to a data type for MySQL and a best guess equivlaents in sqlite for bytea.

After this change, I was able to pass the migration from file-system to db backed pem storage:

mysql@RDS[]> describe private_keys_federation;
+------------+--------------+------+-----+---------+-------+
| Field      | Type         | Null | Key | Default | Extra |
+------------+--------------+------+-----+---------+-------+
| kid        | varchar(255) | NO   | PRI | NULL    |       |
| pem_data   | longblob     | NO   |     | NULL    |       |
| created_at | bigint       | YES  |     | NULL    |       |
| updated_at | bigint       | YES  |     | NULL    |       |
+------------+--------------+------+-----+---------+-------+
4 rows in set (0.03 sec)
mysql@RDS[]> select kid,created_at, updated_at from private_keys_federation;
+---------------------------------------------+------------+------------+
| kid                                         | created_at | updated_at |
+---------------------------------------------+------------+------------+
| redacted | 1781053088 | 1781056091 |
| federation_ES256                            | 1781053088 | 1781056091 |
| federation_ES256f                           | 1781053088 | 1781056091 |
| redacted | 1781053088 | 1781056091 |
+---------------------------------------------+------------+------------+
4 rows in set (0.02 sec)

I also added some test cases, but they seems pretty meh

- Remove unnecessary helper function for dialect mapping.
- Directly use db.Dialector.Name() for column type determination.
- Enhance test coverage for GormDBDataType with a fake dialector.
@deepsource-io

deepsource-io Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

DeepSource Code Review

We reviewed changes in eb089ed...d34ebc2 on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

PR Report Card

Overall Grade   Security  

Reliability  

Complexity  

Hygiene  

Code Review Summary

Analyzer Status Updated (UTC) Details
Go Jun 10, 2026 7:06a.m. Review ↗

Important

AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.

Comment thread storage/model/pem_data_test.go Outdated
@zachmann zachmann merged commit 502cdd4 into go-oidfed:main Jun 10, 2026
3 checks passed
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.

2 participants