Class RowData
java.lang.Object
org.pgcodekeeper.core.model.graph.RowData
Stores database row data for INSERT script generation.
Manages row information including table name, column data, foreign key relationships,
and handles cyclic dependency resolution through null value replacements.
- Author:
- shamsutdinov_er
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddReplacement(String colName) Adds a column for null replacement to resolve cyclic dependencies.voidappendInsert(DatabaseType dbType, boolean haveIdentity, StringBuilder sb) Appends INSERT statement to the script builder.voidappendUpdate(DatabaseType dbType, StringBuilder sb) Appends UPDATE statement to fix cyclic dependency null replacements.booleancontainsAllFkCols(Collection<String> columns) Checks if this row contains all specified foreign key columns.booleangenerateFilter(Object[] foreignColumns, Object[] columns) Generates WHERE clause filter for foreign key relationship.booleanhasFk()Checks if this row has foreign key constraints with NOT NULL columns.inthashCode()toString()
-
Constructor Details
-
RowData
public RowData(String tableName, RowData parent, Map<String, String> data, List<String> fkCols, Collection<String> idCols) Creates a new row data instance.- Parameters:
tableName- qualified name of the tableparent- parent row data for dependency trackingdata- map of column names to valuesfkCols- list of foreign key column names with NOT NULL constraintidCols- collection of identity/primary key column names
-
-
Method Details
-
getTableName
-
getParent
-
hasFk
public boolean hasFk()Checks if this row has foreign key constraints with NOT NULL columns.- Returns:
- true if has foreign key constraints, false otherwise
-
containsAllFkCols
Checks if this row contains all specified foreign key columns.- Parameters:
columns- collection of column names to check- Returns:
- true if all columns are present in foreign key columns
-
addReplacement
Adds a column for null replacement to resolve cyclic dependencies. Only adds columns that have non-null values in the original data.- Parameters:
colName- the column name to replace with null
-
generateFilter
Generates WHERE clause filter for foreign key relationship.- Parameters:
foreignColumns- array of foreign table column namescolumns- array of local table column names- Returns:
- generated filter string, or null if any column value is null
-
appendInsert
Appends INSERT statement to the script builder. Handles database-specific syntax for PostgreSQL and Microsoft SQL.- Parameters:
dbType- the database typehaveIdentity- whether table has identity columnssb- the script builder to append to
-
appendUpdate
Appends UPDATE statement to fix cyclic dependency null replacements. Only generates UPDATE if there are replacement columns.- Parameters:
dbType- the database typesb- the script builder to append to
-
toString
-
hashCode
public int hashCode() -
equals
-