Coverage Report - liquibase.snapshot.jvm.MSSQLDatabaseSnapshotGenerator
 
Classes in this File Line Coverage Branch Coverage Complexity
MSSQLDatabaseSnapshotGenerator
0%
0/12
0%
0/6
2.4
 
 1  
 package liquibase.snapshot.jvm;
 2  
 
 3  
 import liquibase.database.Database;
 4  
 import liquibase.database.core.MSSQLDatabase;
 5  
 import liquibase.database.structure.ForeignKeyConstraintType;
 6  
 import liquibase.exception.DatabaseException;
 7  
 
 8  0
 public class MSSQLDatabaseSnapshotGenerator extends JdbcDatabaseSnapshotGenerator {
 9  
     public boolean supports(Database database) {
 10  0
         return database instanceof MSSQLDatabase;
 11  
     }
 12  
 
 13  
     public int getPriority(Database database) {
 14  0
         return PRIORITY_DATABASE;
 15  
     }
 16  
 
 17  
     @Override
 18  
     protected String convertTableNameToDatabaseTableName(String tableName) {
 19  0
         return tableName;
 20  
     }
 21  
 
 22  
     @Override
 23  
     protected String convertColumnNameToDatabaseTableName(String columnName) {
 24  0
         return columnName;
 25  
     }
 26  
 
 27  
     /**
 28  
      * The sp_fkeys stored procedure spec says that returned integer values of 0, 1 and 2 translate to cascade, noAction
 29  
      * and SetNull, which are not the values in the JDBC standard. This override is a sticking plaster to stop invalid
 30  
      * SQL from being generated.
 31  
      * 
 32  
      * @param JDBC
 33  
      *            foreign constraint type from JTDS (via sys.sp_fkeys)
 34  
      */
 35  
     @Override
 36  
     protected ForeignKeyConstraintType convertToForeignKeyConstraintType(int jdbcType) throws DatabaseException {
 37  
 
 38  0
         if (jdbcType == 0) {
 39  0
             return ForeignKeyConstraintType.importedKeyCascade;
 40  0
         } else if (jdbcType == 1) {
 41  0
             return ForeignKeyConstraintType.importedKeyNoAction;
 42  0
         } else if (jdbcType == 2) {
 43  0
             return ForeignKeyConstraintType.importedKeySetNull;
 44  
         } else {
 45  0
             throw new DatabaseException("Unknown constraint type: " + jdbcType);
 46  
         }
 47  
     }
 48  
 
 49  
 }