File path: /sql12/plugins/dbcopy/src/net/sourceforge/squirrel_sql/plugins/dbcopy/util/DBUtil.java | File path: /sql12/plugins/dbdiff/src/net/sourceforge/squirrel_sql/plugins/dbdiff/util/DBUtil.java | |||
Method name: String getMaxColumnLengthSQL(ISession, TableColumnInfo, String, boolean)
|
Method name: String getMaxColumnLengthSQL(ISession, TableColumnInfo, String, boolean)
|
|||
Number of AST nodes: 22 | Number of AST nodes: 22 | |||
1 | StringBuilder result = new StringBuilder();↵ | 1 | StringBuilder result = new StringBuilder();↵ | |
2 | HibernateDialect dialect = ↵ | 2 | HibernateDialect dialect =↵ | |
3 | DialectFactory.getDialect(↵ | 3 | DialectFactory.getDialect(↵ | |
4 | DialectFactory.SOURCE_TYPE, sourceSession.getApplication().getMainFrame(),↵ | 4 | DialectFactory.SOURCE_TYPE, sourceSession.getApplication().getMainFrame(),↵ | |
5 | sourceSession.getMetaData());↵ | 5 | sourceSession.getMetaData());↵ | |
6 | String lengthFunction = dialect.getLengthFunction(colInfo.getDataType());↵ | 6 | String lengthFunction = dialect.getLengthFunction(colInfo.getDataType());↵ | |
7 | if (lengthFunction == null)↵ | 7 | if (lengthFunction == null)↵ | |
8 | {↵ | 8 | {↵ | |
9 | log.error("Length function is null for dialect=" + dialect.getClass().getName() + ". Using 'length'");↵ | 9 | log.error("Length function is null for dialect=" + dialect.getClass().getName() + ". Using 'length'");↵ | |
10 | lengthFunction = "length";↵ | 10 | lengthFunction = "length";↵ | |
11 | }↵ | 11 | }↵ | |
12 | String maxFunction = dialect.getMaxFunction();↵ | 12 | String maxFunction = dialect.getMaxFunction();↵ | |
13 | if (maxFunction == null)↵ | 13 | if (maxFunction == null)↵ | |
14 | {↵ | 14 | {↵ | |
15 | log.error("Max function is null for dialect=" + dialect.getClass().getName() + ". Using 'max'");↵ | 15 | log.error("Max function is null for dialect=" + dialect.getClass().getName() + ". Using 'max'");↵ | |
16 | maxFunction = "max";↵ | 16 | maxFunction = "max";↵ | |
17 | }↵ | 17 | }↵ | |
18 | result.append("select ");↵ | 18 | result.append("select ");↵ | |
19 | result.append(maxFunction);↵ | 19 | result.append(maxFunction);↵ | |
20 | result.append("(");↵ | 20 | result.append("(");↵ | |
21 | result.append(lengthFunction);↵ | 21 | result.append(lengthFunction);↵ | |
22 | result.append("(");↵ | 22 | result.append("(");↵ | |
23 | result.append(colInfo.getColumnName());↵ | 23 | result.append(colInfo.getColumnName());↵ | |
24 | result.append(")) from ");↵ | 24 | result.append(")) from ");↵ | |
25 | String table = tableName;↵ | 25 | String table = tableName;↵ | |
26 | if (!tableNameIsQualified)↵ | 26 | if (!tableNameIsQualified)↵ | |
27 | {↵ | 27 | {↵ | |
28 | table = ↵ | 28 | table =↵ | |
29 | getQualifiedObjectName(↵ | 29 | getQualifiedObjectName(↵ | |
30 | sourceSession, colInfo.getCatalogName(), colInfo.getSchemaName(), ↵ | 30 | sourceSession, colInfo.getCatalogName(), colInfo.getSchemaName(),↵ | |
31 | tableName,↵ | 31 | tableName,↵ | |
32 | DialectFactory.SOURCE_TYPE);↵ | 32 | DialectFactory.SOURCE_TYPE);↵ | |
33 | }↵ | 33 | }↵ | |
34 | result.append(table);↵ | 34 | result.append(table);↵ | |
35 | return result.toString(); | 35 |
| |
See real code fragment | See real code fragment |
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 1 |
Number of non-refactorable cases | 0 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.4 |
Clones location | Clones are in different classes |
Number of node comparisons | 162 |
Number of mapped statements | 22 |
Number of unmapped statements in the first code fragment | 0 |
Number of unmapped statements in the second code fragment | 0 |
Time elapsed for statement mapping (ms) | 16.5 |
Clone type | Type 2 |
ID | Statement | ID | Statement | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | StringBuilder result = new StringBuilder(); | 1 | StringBuilder result = new StringBuilder(); | |||||||||||
2 | HibernateDialect dialect = DialectFactory.getDialect(DialectFactory.SOURCE_TYPE, sourceSession.getApplication().getMainFrame(), sourceSession.getMetaData()); | 2 | HibernateDialect dialect = DialectFactory.getDialect(DialectFactory.SOURCE_TYPE, sourceSession.getApplication().getMainFrame(), sourceSession.getMetaData()); | |||||||||||
3 | String lengthFunction = dialect.getLengthFunction(colInfo.getDataType()); | 3 | String lengthFunction = dialect.getLengthFunction(colInfo.getDataType()); | |||||||||||
4 | if (lengthFunction == null) | 4 | if (lengthFunction == null) | |||||||||||
5 | log.error("Length function is null for dialect=" + dialect.getClass().getName() + ". Using 'length'"); | 5 | log.error("Length function is null for dialect=" + dialect.getClass().getName() + ". Using 'length'"); | |||||||||||
6 | lengthFunction = "length"; | 6 | lengthFunction = "length"; | |||||||||||
7 | String maxFunction = dialect.getMaxFunction(); | 7 | String maxFunction = dialect.getMaxFunction(); | |||||||||||
8 | if (maxFunction == null) | 8 | if (maxFunction == null) | |||||||||||
9 | log.error("Max function is null for dialect=" + dialect.getClass().getName() + ". Using 'max'"); | 9 | log.error("Max function is null for dialect=" + dialect.getClass().getName() + ". Using 'max'"); | |||||||||||
10 | maxFunction = "max"; | 10 | maxFunction = "max"; | |||||||||||
11 | result.append("select "); | 11 | result.append("select "); | |||||||||||
12 | result.append(maxFunction); | 12 | result.append(maxFunction); | |||||||||||
13 | result.append("("); | 13 | result.append("("); | |||||||||||
14 | result.append(lengthFunction); | 14 | result.append(lengthFunction); | |||||||||||
15 | result.append("("); | 15 | result.append("("); | |||||||||||
16 | result.append(colInfo.getColumnName()); | 16 | result.append(colInfo.getColumnName()); | |||||||||||
17 | result.append(")) from "); | 17 | result.append(")) from "); | |||||||||||
18 | String table = tableName; | 18 | String table = tableName; | |||||||||||
19 | if (!tableNameIsQualified) | 19 | if (!tableNameIsQualified) | |||||||||||
20 | table = getQualifiedObjectName(sourceSession, colInfo.getCatalogName(), colInfo.getSchemaName(), tableName, DialectFactory.SOURCE_TYPE); |
| 20 | table = getQualifiedObjectName(sourceSession, colInfo.getCatalogName(), colInfo.getSchemaName(), tableName, DialectFactory.SOURCE_TYPE); | ||||||||||
21 | result.append(table); | 21 | result.append(table); | |||||||||||
22 | return result.toString(); | 22 | return result.toString(); |
Row | Violation |
---|