[jOOQ/jOOQ#9425] Support sequence flag changes in Diff

`Diff` now emits `ALTER SEQUENCE` statements for differences in the
flags of a given sequence.
This commit is contained in:
Knut Wannheden 2019-11-21 09:24:40 +01:00
parent d8bf2b48d8
commit f5e5fb71a1
3 changed files with 64 additions and 15 deletions

View File

@ -143,6 +143,8 @@ final class AlterSequenceImpl<T extends Number> extends AbstractRowCountQuery im
final Sequence<?> $sequence() { return sequence; }
final boolean $ifExists() { return ifExists; }
final Sequence<?> $renameTo() { return renameTo; }
final boolean $restart() { return restart; }
final Field<?> $restartWith() { return restartWith; }
final Field<? extends Number> $startWith() { return startWith; }
final Field<? extends Number> $incrementBy() { return incrementBy; }
final Field<? extends Number> $minvalue() { return minvalue; }

View File

@ -726,34 +726,42 @@ final class DDLInterpreter {
}
else {
Field<? extends Number> startWith = query.$startWith();
if (startWith != null)
boolean seen = false;
if (startWith != null && (seen |= true))
existing.startWith = startWith;
Field<? extends Number> incrementBy = query.$incrementBy();
if (incrementBy != null)
if (incrementBy != null && (seen |= true))
existing.incrementBy = incrementBy;
Field<? extends Number> minvalue = query.$minvalue();
if (minvalue != null)
if (minvalue != null && (seen |= true))
existing.minValue = minvalue;
else if (query.$noMinvalue())
else if (query.$noMinvalue() && (seen |= true))
existing.minValue = null;
Field<? extends Number> maxvalue = query.$maxvalue();
if (maxvalue != null)
if (maxvalue != null && (seen |= true))
existing.maxValue = maxvalue;
else if (query.$noMaxvalue())
else if (query.$noMaxvalue() && (seen |= true))
existing.maxValue = null;
Boolean cycle = query.$cycle();
if (cycle != null)
if (cycle != null && (seen |= true))
existing.cycle = cycle;
Field<? extends Number> cache = query.$cache();
if (cache != null)
if (cache != null && (seen |= true))
existing.cache = cache;
else if (query.$noCache())
else if (query.$noCache() && (seen |= true))
existing.cache = null;
if ((query.$restart() || query.$restartWith() != null) && (seen |= true))
// ignored
;
if (!seen)
throw unsupportedQuery(query);
}
}
@ -1436,12 +1444,12 @@ final class DDLInterpreter {
@SuppressWarnings("unchecked")
InterpretedSequence(Schema schema) {
super(MutableSequence.this.name, schema, BIGINT, false,
(Field<Long>) startWith,
(Field<Long>) incrementBy,
(Field<Long>) minValue,
(Field<Long>) maxValue,
cycle,
(Field<Long>) cache);
(Field<Long>) MutableSequence.this.startWith,
(Field<Long>) MutableSequence.this.incrementBy,
(Field<Long>) MutableSequence.this.minValue,
(Field<Long>) MutableSequence.this.maxValue,
MutableSequence.this.cycle,
(Field<Long>) MutableSequence.this.cache);
}
}
}

View File

@ -588,6 +588,45 @@ package org.jooq.impl;