Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
semint-kprime-arm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pedot Nicola
semint-kprime-arm
Commits
a6cad567
Commit
a6cad567
authored
4 years ago
by
npedot
Browse files
Options
Downloads
Patches
Plain Diff
adds drop table, drop constraint
parent
4fbbb10e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/kotlin/unibz.cs.semint.kprime/domain/ddl/Schema.kt
+18
-0
18 additions, 0 deletions
src/main/kotlin/unibz.cs.semint.kprime/domain/ddl/Schema.kt
src/test/kotlin/unibz.cs.semint.kprime/domain/SchemaTest.kt
+27
-3
27 additions, 3 deletions
src/test/kotlin/unibz.cs.semint.kprime/domain/SchemaTest.kt
with
45 additions
and
3 deletions
src/main/kotlin/unibz.cs.semint.kprime/domain/ddl/Schema.kt
+
18
−
0
View file @
a6cad567
...
...
@@ -120,6 +120,24 @@ class Schema () {
return
this
}
fun
dropTable
(
commandArgs
:
String
)
:
Schema
{
var
tableNames
=
commandArgs
.
split
(
" "
)
for
(
tableName
in
tableNames
)
{
var
table
=
table
(
tableName
)
tables
().
remove
(
table
)
}
return
this
}
fun
dropConstraint
(
commnadArgs
:
String
)
:
Schema
{
var
constraintNames
=
commnadArgs
.
split
(
" "
)
for
(
constraintName
in
constraintNames
)
{
var
constraint
=
constraint
(
constraintName
)
constraints
().
remove
(
constraint
)
}
return
this
}
fun
addFunctional
(
tableName
:
String
,
setExpression
:
String
):
Schema
{
val
constraintsToAdd
=
Constraint
.
set
(
setExpression
)
for
(
constraint
in
constraintsToAdd
)
{
...
...
This diff is collapsed.
Click to expand it.
src/test/kotlin/unibz.cs.semint.kprime/domain/SchemaTest.kt
+
27
−
3
View file @
a6cad567
...
...
@@ -3,9 +3,7 @@ package unibz.cs.semint.kprime.domain
import
junit.framework.TestCase.assertEquals
import
junit.framework.TestCase.assertTrue
import
org.junit.Test
import
unibz.cs.semint.kprime.domain.ddl.Column
import
unibz.cs.semint.kprime.domain.ddl.Constraint
import
unibz.cs.semint.kprime.domain.ddl.Schema
import
unibz.cs.semint.kprime.domain.ddl.*
class
SchemaTest
{
...
...
@@ -221,4 +219,30 @@ class SchemaTest {
assertEquals
(
1
,
schema
.
doubleIncs
().
size
)
}
@Test
fun
test_dropTable
()
{
// given
var
schema
=
Schema
()
schema
.
addTable
(
"person:name,surname"
)
assertEquals
(
1
,
schema
.
tables
().
size
)
// when
schema
.
dropTable
(
"person"
)
// then
assertEquals
(
0
,
schema
.
tables
().
size
)
}
@Test
fun
test_dropConstraint
()
{
// given
var
schema
=
Schema
()
schema
.
addKey
(
"person:id"
)
schema
.
addForeignKey
(
"person:id-->employee:id"
)
assertEquals
(
2
,
schema
.
constraints
().
size
)
// when
schema
.
dropConstraint
(
"person.primaryKey"
)
schema
.
dropConstraint
(
"person_employee.foreignKey"
)
// then
assertEquals
(
0
,
schema
.
constraints
().
size
)
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment