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

Rip useless names out of RawDef #1918

Merged
merged 8 commits into from
Nov 20, 2024
Merged

Rip useless names out of RawDef #1918

merged 8 commits into from
Nov 20, 2024

Conversation

kazimuth
Copy link
Contributor

@kazimuth kazimuth commented Oct 28, 2024

Description of Changes

Addresses #1893
Does NOT address #1891 since the special names turned out to be used throughout the codebase and I think addressing that will require a separate big PR.

While we're reworking naming, we may want to revisit the naming scheme here. It has a problem.
Consider the following declaration:

#[spacetimedb(table)]
#[derive(Clone, Debug)]
#[spacetimedb(index(name = "idx1", btree(columns = [a, b]))]
#[spacetimedb(index(name = "idx2", btree(columns = [a_b]))]
pub struct EdgeCase {
    pub a: u32,
    pub b: u32,
    pub a_b: u64,
}

These indexes will BOTH receive the generated name "idx_EdgeCase_btree_a_b". Weird errors result.

(idx1 and idx2 are now referred to as accessor_names and are stored separately from the name of the index itself.)

It would be better if we used out-of-band characters in the index name, like, say, "EdgeCase.index.btree([a,b])". However, if we do this, we will need to relax the Identifier validation rules for indexes, since normally those will reject special characters. Also, it means that these identifiers can no longer be used directly as identifiers in SQL. @mamcx, I would welcome your opinion on this. I think it's fine, since system table queries can just wrap names in quotes.

We could also use a more elaborate mangling scheme, but this may penalize readability of the system tables.

API and ABI breaking changes

ABI breaking.

Expected complexity level and risk

Reduces complexity overall so let's say 2->1.

Testing

Fixed all relevant tests.

@kazimuth kazimuth added the abi-break A PR that makes an ABI breaking change label Oct 28, 2024
Copy link
Contributor

@RReverser RReverser left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM. My only comments would be what's already covered by your TODOs.

@mamcx
Copy link
Contributor

mamcx commented Oct 30, 2024

I don't understand why it will generate "idx_EdgeCase_btree_a_b". I expect it to be "idx1_EdgeCase_btree_a_b"/"idx2_EdgeCase_btree_a_b"

@kazimuth
Copy link
Contributor Author

Ah, that's because the name in the macro is now called accessor_name and is separate from the name of the index itself, that name is intended to only be used in codegen.

@kazimuth
Copy link
Contributor Author

kazimuth commented Nov 5, 2024

@kazimuth
Copy link
Contributor Author

I think the remaining test failure here could be related to #1987 so I'm going to work on that first.

@kazimuth kazimuth force-pushed the jgilles/unname branch 3 times, most recently from 7673681 to ad9593b Compare November 18, 2024 21:39
@kazimuth
Copy link
Contributor Author

The internal test failures here seem unrelated to what I'm doing, it's a rocksdb compilation failure :/

Copy link
Contributor

@cloutiertyler cloutiertyler left a comment

Choose a reason for hiding this comment

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

Please see comment.

@kazimuth
Copy link
Contributor Author

@cloutiertyler fixed, now we're using the postgres convention everywhere

Copy link
Contributor

@cloutiertyler cloutiertyler left a comment

Choose a reason for hiding this comment

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

Test suite is failing, but this now LGTM from my perspective on names

Fix CLI jankily

Remove dead comment

Implement name generation policy change (private #915 WIP)

Update bindings and cli to handle new name format

Clippy my nemesis

Finish updating csharp module bindings

And fix names

WIP

Placate csharpier

Final fixes

Fix schema doctests

Ah, C# is seeing the autogenerated names despite being on v8 still

Add test

WIP

Previous c# fix could not work due to v8. This one can work until the upgrade

Format
@kazimuth kazimuth added this pull request to the merge queue Nov 20, 2024
Merged via the queue into master with commit c657b4f Nov 20, 2024
8 checks passed
@kazimuth kazimuth deleted the jgilles/unname branch November 20, 2024 21:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
abi-break A PR that makes an ABI breaking change release-1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants