Skip to content

Commit 41f0fc3

Browse files
committed
Bug fix: #1531 MySQL Plugin: SMALLINT UNSIGNED columns showed <Error> when the fields value exceeded 32767.
Note: To work with MYSQL SMALLINT UNSIGNED or TINYINT UNSIGNED types the MySQL Plugin must be installed.
1 parent a53cc59 commit 41f0fc3

File tree

6 files changed

+103
-35
lines changed

6 files changed

+103
-35
lines changed

sql12/core/doc/changes.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ Table cell data popup now offers find, Xml/Json-reformatting and export function
7474

7575
Bug fixes:
7676

77+
#1531 MySQL Plugin: SMALLINT UNSIGNED columns showed <Error> when the fields value exceeded 32767.
78+
Note: To work with MYSQL SMALLINT UNSIGNED or TINYINT UNSIGNED types the MySQL Plugin must be installed.
79+
7780
SQL editor/SQL result tabs/marking SQL result tab headers:
7881
Memory and CPU usage was improved in case SQLs where compared
7982
disregarding comments line feeds and other white spaces.

sql12/plugins/mysql/src/net/sourceforge/squirrel_sql/plugins/mysql/MysqlPlugin.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@
8181
import net.sourceforge.squirrel_sql.plugins.mysql.tab.UserGrantsTab;
8282
import net.sourceforge.squirrel_sql.plugins.mysql.tokenizer.MysqlQueryTokenizer;
8383
import net.sourceforge.squirrel_sql.plugins.mysql.types.MySQL5ByteTypeDataTypeComponentFactory;
84+
import net.sourceforge.squirrel_sql.plugins.mysql.types.MySQL5SmallIntTypeDataTypeComponentFactory;
8485
import net.sourceforge.squirrel_sql.plugins.mysql.types.MySQLByteTypeDataTypeComponentFactory;
86+
import net.sourceforge.squirrel_sql.plugins.mysql.types.MySQLSmallIntTypeDataTypeComponentFactory;
8587

8688
import javax.swing.JMenu;
8789

@@ -289,9 +291,12 @@ public synchronized void initialize() throws PluginException
289291

290292
/* Register custom DataTypeComponent factory for MySQL TINYINT UNSIGNED type */
291293
Main.getApplication().getDataTypeComponentFactoryRegistry().registerDataTypeFactory(new MySQLByteTypeDataTypeComponentFactory());
292-
/* Register custom DataTypeComponent factory for MySQL TINYINT UNSIGNED type */
293294
Main.getApplication().getDataTypeComponentFactoryRegistry().registerDataTypeFactory(new MySQL5ByteTypeDataTypeComponentFactory());
294295

296+
/* Register custom DataTypeComponent factory for MySQL SMALLINT UNSIGNED type */
297+
Main.getApplication().getDataTypeComponentFactoryRegistry().registerDataTypeFactory(new MySQLSmallIntTypeDataTypeComponentFactory());
298+
Main.getApplication().getDataTypeComponentFactoryRegistry().registerDataTypeFactory(new MySQL5SmallIntTypeDataTypeComponentFactory());
299+
295300
}
296301

297302
/**

sql12/plugins/mysql/src/net/sourceforge/squirrel_sql/plugins/mysql/types/MySQL5ByteTypeDataTypeComponentFactory.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
/**
77
* A factory that creates Data for rendering columns of
88
* {@code DB2Types.XML}.
9-
*
109
*/
11-
public class MySQL5ByteTypeDataTypeComponentFactory extends MySQLByteTypeDataTypeComponentFactory {
12-
13-
/**
14-
* @see net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.IDataTypeComponentFactory#getDialectType()
15-
*/
16-
public DialectType getDialectType() {
17-
return DialectType.MYSQL5;
18-
}
10+
public class MySQL5ByteTypeDataTypeComponentFactory extends MySQLByteTypeDataTypeComponentFactory
11+
{
1912

13+
/**
14+
* @see net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.IDataTypeComponentFactory#getDialectType()
15+
*/
16+
public DialectType getDialectType()
17+
{
18+
return DialectType.MYSQL5;
19+
}
2020
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
package net.sourceforge.squirrel_sql.plugins.mysql.types;
3+
4+
import net.sourceforge.squirrel_sql.fw.dialects.DialectType;
5+
6+
/**
7+
* A factory that creates Data for rendering columns of
8+
* {@code DB2Types.XML}.
9+
*
10+
*/
11+
public class MySQL5SmallIntTypeDataTypeComponentFactory extends MySQLSmallIntTypeDataTypeComponentFactory {
12+
13+
/**
14+
* @see net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.IDataTypeComponentFactory#getDialectType()
15+
*/
16+
public DialectType getDialectType() {
17+
return DialectType.MYSQL5;
18+
}
19+
20+
}

sql12/plugins/mysql/src/net/sourceforge/squirrel_sql/plugins/mysql/types/MySQLByteTypeDataTypeComponentFactory.java

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,34 +9,30 @@
99

1010
/**
1111
* A factory that creates DataTypeShort for rendering columns of MySQL TINYINT UNSIGNED.
12-
*
1312
*/
14-
public class MySQLByteTypeDataTypeComponentFactory implements
15-
IDataTypeComponentFactory {
13+
public class MySQLByteTypeDataTypeComponentFactory implements IDataTypeComponentFactory
14+
{
1615

17-
/**
18-
* @see net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.IDataTypeComponentFactory#constructDataTypeComponent()
19-
*/
20-
@Override
21-
public IDataTypeComponent constructDataTypeComponent() {
22-
return new DataTypeShort(null, new ColumnDisplayDefinition(10, "dummy"));
23-
}
16+
@Override
17+
public IDataTypeComponent constructDataTypeComponent()
18+
{
19+
return new DataTypeShort(null, new ColumnDisplayDefinition(10, "dummy"));
20+
}
2421

25-
/**
26-
* @see net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.IDataTypeComponentFactory#getDialectType()
27-
*/
28-
@Override
29-
public DialectType getDialectType() {
30-
return DialectType.MYSQL;
31-
}
22+
@Override
23+
public DialectType getDialectType()
24+
{
25+
return DialectType.MYSQL;
26+
}
3227

33-
34-
@Override
35-
public boolean matches(DialectType dialectType, int sqlType,
36-
String sqlTypeName) {
37-
return new EqualsBuilder().append(getDialectType(), dialectType)
38-
.append(-6, sqlType)
39-
.append("TINYINT UNSIGNED", sqlTypeName).isEquals();
40-
}
28+
29+
@Override
30+
public boolean matches(DialectType dialectType, int sqlType,
31+
String sqlTypeName)
32+
{
33+
return new EqualsBuilder().append(getDialectType(), dialectType)
34+
.append(-6, sqlType)
35+
.append("TINYINT UNSIGNED", sqlTypeName).isEquals();
36+
}
4137

4238
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package net.sourceforge.squirrel_sql.plugins.mysql.types;
2+
3+
import net.sourceforge.squirrel_sql.fw.datasetviewer.ColumnDisplayDefinition;
4+
import net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.DataTypeInteger;
5+
import net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.IDataTypeComponent;
6+
import net.sourceforge.squirrel_sql.fw.datasetviewer.cellcomponent.IDataTypeComponentFactory;
7+
import net.sourceforge.squirrel_sql.fw.dialects.DialectType;
8+
import org.apache.commons.lang3.builder.EqualsBuilder;
9+
10+
/**
11+
* A factory that creates DataTypeShort for rendering columns of MySQL SMALLINT UNSIGNED.
12+
*/
13+
public class MySQLSmallIntTypeDataTypeComponentFactory implements IDataTypeComponentFactory
14+
{
15+
16+
/**
17+
* @see IDataTypeComponentFactory#constructDataTypeComponent()
18+
*/
19+
@Override
20+
public IDataTypeComponent constructDataTypeComponent()
21+
{
22+
return new DataTypeInteger(null, new ColumnDisplayDefinition(20, "dummy"));
23+
}
24+
25+
/**
26+
* @see IDataTypeComponentFactory#getDialectType()
27+
*/
28+
@Override
29+
public DialectType getDialectType()
30+
{
31+
return DialectType.MYSQL;
32+
}
33+
34+
35+
@Override
36+
public boolean matches(DialectType dialectType, int sqlType,
37+
String sqlTypeName)
38+
{
39+
return new EqualsBuilder().append(getDialectType(), dialectType)
40+
.append(5, sqlType)
41+
.append("SMALLINT UNSIGNED", sqlTypeName).isEquals();
42+
}
43+
44+
}

0 commit comments

Comments
 (0)