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

switch configuration types to maps #12

Merged
merged 1 commit into from
Mar 25, 2024
Merged

Conversation

hallettj
Copy link
Collaborator

In some earlier feedback @dmoverton pointed out it would be better to store native queries in maps, as opposed to vecs. I thought the same logic would apply to some of the other configuration fields. It's also been bugging me that the configuration formats didn't match pattern in ddn and ndc-postgres in that we were using lists of named objects instead of maps.

I switched over some types from Vec<StructWithNameField> to BTreeMap<String, StructWithoutNameField>. To smooth things out I also added a WithName type that can wrap any struct, and adds a name field that appears at the same level as the underlying struct's fields in serialized formats. That lets us deserialize either without a name (for example if we're getting names from map keys in schema.json instead of from map value fields), or with a name (like if we split up schema configuration to put info for each collection into it's own file, we'll want to read the name from a field in the file.) I used that method to update read_subdir_configs in directory.rs so that it automatically grabs a name from each file.

The changes ended up being more extensive than I'd hoped so let me know if it's too much. But since this changes configuration formats I thought if we want to make this change it's better not to wait.

https://hasurahq.atlassian.net/browse/MDB-91

Copy link
Collaborator

@dmoverton dmoverton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

@hallettj hallettj merged commit 2bcbfd3 into main Mar 25, 2024
2 checks passed
@hallettj hallettj deleted the switch-to-maps-in-configuration branch March 25, 2024 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants