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

Use the specified the index name above the default name #60

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Joannis
Copy link
Member

@Joannis Joannis commented Jun 11, 2023

No description provided.

@Joannis Joannis requested a review from gwynne June 11, 2023 11:18
@Joannis Joannis marked this pull request as ready for review June 11, 2023 11:18
Copy link
Member

@gwynne gwynne left a comment

Choose a reason for hiding this comment

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

A couple concerns

Sources/FluentMongoDriver/MongoDB+Schema.swift Outdated Show resolved Hide resolved
func prepare(on database: Database) -> EventLoopFuture<Void> {
database
.schema("index-tests")
.field("name", .string, .required)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
.field("name", .string, .required)
.compositeIdentifier(over: "name", "email")
.field("name", .string, .required)

In light of my remarks above (and since it'll just translate to an additional unique index for Mongo)

@@ -146,6 +146,10 @@ final class FluentMongoDriverTests: XCTestCase {
XCTFail("\(error)")
}
}

func testDuplicateIndexNames() throws {
XCTAssertNoThrow(try DuplicateIndexMigration().prepare(on: self.db).wait())
Copy link
Member

Choose a reason for hiding this comment

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

IIUC this won't actually test anything; the original reporter said in Discord that only one index gets created, not that an error is thrown. Is there a way to verify the indexes were actually added? Or alternatively, can we either 1) check for duplicates and throw an error in the schema logic, or 2) ask MongoDB to reject duplicates somehow?

@gwynne gwynne added the semver-patch Internal changes only label Jun 11, 2023
@codecov-commenter
Copy link

Codecov Report

Merging #60 (76578ce) into main (a4237b9) will increase coverage by 0.46%.
The diff coverage is 100.00%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #60      +/-   ##
==========================================
+ Coverage   72.59%   73.05%   +0.46%     
==========================================
  Files          20       20              
  Lines         686      694       +8     
==========================================
+ Hits          498      507       +9     
+ Misses        188      187       -1     
Impacted Files Coverage Δ
Sources/FluentMongoDriver/MongoDB+Schema.swift 95.31% <100.00%> (+2.45%) ⬆️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver-patch Internal changes only
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants