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

Remove the unique suggestions index #6692

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -746,10 +746,10 @@ class SuggestionsHandlerSpec
inserted(0),
inserted(1),
inserted(2),
inserted(3),
inserted(6),
inserted(7),
inserted(8),
inserted(3)
inserted(8)
)
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,29 +164,12 @@ final class SuggestionsTable(tag: Tag)
(SuggestionRow.tupled, SuggestionRow.unapply)

def moduleIdx = index("suggestions_module_idx", module)
def name_idx = index("suggestions_name_idx", name)
def nameIdx = index("suggestions_name_idx", name)
def selfTypeIdx = index("suggestions_self_type_idx", selfType)
def returnTypeIdx = index("suggestions_return_type_idx", returnType)
def externalIdIdx =
index("suggestions_external_id_idx", (externalIdLeast, externalIdMost))
def reexportIdx = index("suggestions_reexport_idx", reexport)
// NOTE: unique index should not contain nullable columns because SQLite
// teats NULLs as distinct values.
def uniqueIdx =
index(
"suggestions_unique_idx",
(
kind,
module,
name,
selfType,
scopeStartLine,
scopeStartOffset,
scopeEndLine,
scopeEndOffset
),
unique = true
)
}

/** An element of unique suggestion index.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package org.enso.searcher.sql

import java.nio.file.{Files, Path}
import java.util.UUID
import org.enso.polyglot.{ExportedSymbol, ModuleExports, Suggestion}
import org.enso.polyglot.runtime.Runtime.Api
import org.enso.polyglot.{ExportedSymbol, ModuleExports, Suggestion}
import org.enso.searcher.SuggestionEntry
import org.enso.searcher.data.QueryResult
import org.enso.searcher.sql.equality.SuggestionsEquality
Expand All @@ -12,7 +10,8 @@ import org.scalactic.TripleEqualsSupport
import org.scalatest.matchers.should.Matchers
import org.scalatest.wordspec.AnyWordSpec

import java.sql.SQLException
import java.nio.file.{Files, Path}
import java.util.UUID

import scala.concurrent.Await
import scala.concurrent.ExecutionContext.Implicits.global
Expand Down Expand Up @@ -125,16 +124,6 @@ class SuggestionsRepoTest
)
}

"fail to insertAll duplicate suggestion" taggedAs Retry in withRepo {
repo =>
val action =
for {
_ <- repo.insertAll(Seq(suggestion.local, suggestion.local))
} yield ()

an[SQLException] should be thrownBy Await.result(action, Timeout)
}

"select suggestion by id" taggedAs Retry in withRepo { repo =>
val action =
for {
Expand Down Expand Up @@ -215,21 +204,6 @@ class SuggestionsRepoTest
v1 should not equal v2
}

"not change version after failed insert" taggedAs Retry in withRepo {
repo =>
val action = for {
v1 <- repo.currentVersion
_ <- repo.insert(suggestion.constructor)
v2 <- repo.currentVersion
_ <- repo.insert(suggestion.constructor)
v3 <- repo.currentVersion
} yield (v1, v2, v3)

val (v1, v2, v3) = Await.result(action, Timeout)
v1 should not equal v2
v2 shouldEqual v3
}

"change version after remove" taggedAs Retry in withRepo { repo =>
val action = for {
v1 <- repo.currentVersion
Expand Down