[jOOQ/jOOQ#10010] Rename Loader { CSV | JSON | Rows } Step.fieldsFromSource() to fieldsCorresponding()
This commit is contained in:
parent
0b21120fb2
commit
e624f5f28f
@ -107,12 +107,23 @@ public interface LoaderCSVStep<R extends Record> {
|
||||
/**
|
||||
* Indicate that all input fields which have a corresponding field in the
|
||||
* target table (with the same name) should be loaded.
|
||||
* <p>
|
||||
* When {@link LoaderLoadStep#execute() executing the loader} input fields
|
||||
* for which there is no match in the target table will be logged and if no
|
||||
* field names can be derived for the input data a
|
||||
* {@link LoaderConfigurationException} will be reported.
|
||||
*
|
||||
* @throws LoaderConfigurationException When the source data does not expose
|
||||
* field names.
|
||||
* @deprecated - 3.14.0 - [#10010] - Use {@link #fieldsCorresponding()}
|
||||
* instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@Support
|
||||
LoaderCSVOptionsStep<R> fieldsFromSource();
|
||||
|
||||
/**
|
||||
* Indicate that all input fields which have a corresponding field in the
|
||||
* target table (with the same name) should be loaded.
|
||||
*
|
||||
* @throws LoaderConfigurationException When the source data does not expose
|
||||
* field names.
|
||||
*/
|
||||
@Support
|
||||
LoaderCSVOptionsStep<R> fieldsCorresponding();
|
||||
}
|
||||
|
||||
@ -91,12 +91,24 @@ public interface LoaderJSONStep<R extends Record> {
|
||||
/**
|
||||
* Indicate that all input fields which have a corresponding field in the
|
||||
* target table (with the same name) should be loaded.
|
||||
* <p>
|
||||
* When {@link LoaderLoadStep#execute() executing the loader} input fields
|
||||
* for which there is no match in the target table will be logged and if no
|
||||
* field names can be derived for the input data a
|
||||
* {@link LoaderConfigurationException} will be reported.
|
||||
*
|
||||
* @throws LoaderConfigurationException When the source data does not expose
|
||||
* field names.
|
||||
* @deprecated - 3.14.0 - [#10010] - Use {@link #fieldsCorresponding()}
|
||||
* instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@Support
|
||||
LoaderCSVOptionsStep<R> fieldsFromSource();
|
||||
|
||||
/**
|
||||
* Indicate that all input fields which have a corresponding field in the
|
||||
* target table (with the same name) should be loaded.
|
||||
*
|
||||
* @throws LoaderConfigurationException When the source data does not expose
|
||||
* field names.
|
||||
*/
|
||||
@Support
|
||||
LoaderJSONOptionsStep<R> fieldsFromSource();
|
||||
LoaderCSVOptionsStep<R> fieldsCorresponding();
|
||||
|
||||
}
|
||||
|
||||
@ -107,12 +107,24 @@ public interface LoaderRowsStep<R extends Record> {
|
||||
/**
|
||||
* Indicate that all input fields which have a corresponding field in the
|
||||
* target table (with the same name) should be loaded.
|
||||
* <p>
|
||||
* When {@link LoaderLoadStep#execute() executing the loader} input fields
|
||||
* for which there is no match in the target table will be logged and if no
|
||||
* field names can be derived for the input data a
|
||||
* {@link LoaderConfigurationException} will be reported.
|
||||
*
|
||||
* @throws LoaderConfigurationException When the source data does not expose
|
||||
* field names.
|
||||
* @deprecated - 3.14.0 - [#10010] - Use {@link #fieldsCorresponding()}
|
||||
* instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@Support
|
||||
LoaderCSVOptionsStep<R> fieldsFromSource();
|
||||
|
||||
/**
|
||||
* Indicate that all input fields which have a corresponding field in the
|
||||
* target table (with the same name) should be loaded.
|
||||
*
|
||||
* @throws LoaderConfigurationException When the source data does not expose
|
||||
* field names.
|
||||
*/
|
||||
@Support
|
||||
LoaderListenerStep<R> fieldsFromSource();
|
||||
LoaderCSVOptionsStep<R> fieldsCorresponding();
|
||||
|
||||
}
|
||||
|
||||
@ -159,7 +159,7 @@ final class LoaderImpl<R extends Record> implements
|
||||
private Field<?>[] source;
|
||||
private Field<?>[] fields;
|
||||
private LoaderFieldMapper fieldMapper;
|
||||
private boolean fieldsFromSource;
|
||||
private boolean fieldsCorresponding;
|
||||
private boolean[] primaryKey;
|
||||
|
||||
// Result data
|
||||
@ -552,8 +552,14 @@ final class LoaderImpl<R extends Record> implements
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public LoaderImpl<R> fieldsFromSource() {
|
||||
fieldsFromSource = true;
|
||||
return fieldsCorresponding();
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoaderImpl<R> fieldsCorresponding() {
|
||||
fieldsCorresponding = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -563,8 +569,8 @@ final class LoaderImpl<R extends Record> implements
|
||||
// [#5145] When loading arrays, or when CSV headers are ignored,
|
||||
// the source is still null at this stage.
|
||||
if (source == null)
|
||||
if (fieldsFromSource)
|
||||
throw new LoaderConfigurationException("Using fieldsFromSource() requires field names to be available in source.");
|
||||
if (fieldsCorresponding)
|
||||
throw new LoaderConfigurationException("Using fieldsCorresponding() requires field names to be available in source.");
|
||||
else
|
||||
source = Tools.fields(row.length);
|
||||
|
||||
@ -585,7 +591,7 @@ final class LoaderImpl<R extends Record> implements
|
||||
});
|
||||
}
|
||||
|
||||
else if (fieldsFromSource)
|
||||
else if (fieldsCorresponding)
|
||||
for (int i = 0; i < row.length; i++) {
|
||||
f[i] = table.field(source[i]);
|
||||
if (f[i] == null)
|
||||
@ -743,7 +749,7 @@ final class LoaderImpl<R extends Record> implements
|
||||
row = Arrays.copyOf(row, row.length, Object[].class);
|
||||
|
||||
// [#5145][#8755] Lazy initialisation of fields from the first row
|
||||
// in case fields(LoaderFieldMapper) or fieldsFromSource() was used
|
||||
// in case fields(LoaderFieldMapper) or fieldsCorresponding() was used
|
||||
if (fields == null)
|
||||
fields0(row);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user