Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Duplicate
-
Affects Version/s: 1.0.2
-
Fix Version/s: None
-
Component/s: Persistence
-
Labels:None
-
Testcase included:yes
Description
Given a simple domain class like this:
class Book {
String title
}
Grails will create a database table called "Book" and a column called "title" with a default length of VARCHAR 255. If you set a value into the "title" attribute of Book that is longer than 255 characters, validation will not prevent hibernate from trying to save the object - so you end up with a JDBC exception that the value for the database column exceeds the size of the column.
Is it possible to have validation validate the default size (i.e. 255) without having to explicitly define a maxSize constraint for String properties?
The workaround for this is to specify size or maxSize constraints for ALL string properties on domain objects.
Sample application with test case attached.
-
Hide
- maxSize-bug-report-05052008.zip
- 05/May/08 10:22 AM
- 32 kB
- Mike Hugo
-
- grails-app/conf/BootStrap.groovy 0.1 kB
- grails-app/conf/Config.groovy 3 kB
- grails-app/conf/DataSource.groovy 0.6 kB
- grails-app/conf/UrlMappings.groovy 0.2 kB
- grails-app/conf/spring/resources.groovy 0.0 kB
- grails-app/domain/Book.groovy 0.0 kB
- grails-app/i18n/messages.properties 2 kB
- grails-app/i18n/messages_de.properties 3 kB
- grails-app/i18n/messages_es.properties 3 kB
- grails-app/i18n/messages_fr.properties 2 kB
- grails-app/i18n/messages_it.properties 2 kB
- grails-app/i18n/messages_ja.properties 2 kB
- grails-app/i18n/messages_nl.properties 3 kB
- grails-app/i18n/messages_ru.properties 4 kB
- grails-app/i18n/messages_th.properties 5 kB
- grails-app/.../messages_zh_CN.properties 2 kB
- grails-app/views/error.gsp 1 kB
- grails-app/views/layouts/main.gsp 0.7 kB
- test/integration/BookTests.groovy 0.6 kB
- test/reports/TEST-BookTests-err.txt 0.1 kB
- test/reports/TEST-BookTests-out.txt 0.1 kB
- test/reports/TEST-BookTests.xml 20 kB
- test/reports/TESTS-TestSuites.xml 20 kB
- test/reports/html/0_BookTests-err.txt 0.1 kB
- test/reports/html/0_BookTests-fails.html 24 kB
- test/reports/html/0_BookTests-out.txt 0.1 kB
- test/reports/html/0_BookTests.html 24 kB
- test/reports/html/all-tests.html 22 kB
- test/reports/html/allclasses-frame.html 0.5 kB
- test/reports/html/alltests-errors.html 0.8 kB
Activity
- All
- Comments
- Work Log
- History
- Activity
- Git Commits
This is a duplicate of: http://jira.grails.org/browse/GRAILS-7323