Icon View Thread

The following is the text of the current message along with any replies.
Messages 11 to 15 of 15 total
Thread TEdit's MaxLength Not Respected
Wed, Aug 1 2018 11:41 AMPermanent Link

Frederick Chin

Raul wrote:

/*
So if one were to modify the record and write it back to database would
you be OK if it's now truncated to control max length ?
*/

Yes, why not? As the developer, I set the MaxLength to an appropriate value because it is needed and I am doing so to maintain the correctness of the data written.

--
Frederick
Wed, Aug 1 2018 11:48 AMPermanent Link

Raul

Team Elevate Team Elevate

On 8/1/2018 11:41 AM, Frederick Chin wrote:
>
> Yes, why not? As the developer, I set the MaxLength to an appropriate value because it is needed and I am doing so to maintain the correctness of the data written.
>

Because now you're putting business logic into the front end so
everything that updates that data has to implement all the rules.


Curious what Tim says since this does represent interesting conflict.

- if EWB app enforces shorter max length than DB then one can truncate
data when saving data back that was longer
- if EWB app enforces longer max length than then DB will truncate value
user entered once record is posted

Raul
Wed, Aug 1 2018 6:31 PMPermanent Link

Frederick Chin

Raul wrote:

/*
Because now you're putting business logic into the front end so
everything that updates that data has to implement all the rules.
*/

I don't see this as a hindrance if it gets the job done with a simple property change.

I'll give you another example. Let's say I am creating an application that will be used in two countries. One country requires the field to be 5 characters wide while another needs it to be 10 characters. If I were to create the table, the field would be 10 characters wide. In the EWB application, I can just set the MaxLength property to 5 for one country and 0 for the other.

/*
- if EWB app enforces shorter max length than DB then one can truncate
data when saving data back that was longer
*/

Truncation sounds like you are damaging data. It is more like data input validation before the data is saved to the DB.

/*
- if EWB app enforces longer max length than then DB will truncate value
user entered once record is posted
*/

I doubt that a developer would consciously set a MaxLength greater than the table's field width but the user will complain if their entered data were to be cut off.

--
Frederick
Wed, Aug 1 2018 6:38 PMPermanent Link

Walter Matte

Tactical Business Corporation

Frederick Chin wrote:

"A simple property change is better than fooling around with the data definition."

Setting the length in the Field Definition - it is a Property!

I like the framework the way it is.  I don't like the Delphi behavour you describe.

Walter
Mon, Aug 6 2018 2:30 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Frederick,

<< Yes, why not? As the developer, I set the MaxLength to an appropriate value because it is needed and I am doing so to maintain the correctness of the data written. >>

Some database servers/engines will issue an exception/error if the data is truncated during modification. It's actually in the SQL spec and ODBC spec.

As for fixing this issue: is there any reason why you don't just change the length of the TDataColumn instance ?  EWB doesn't care, either way, and you can set up multiple datasets that use the same underlying server-side dataset, but each with different field definitions.

Tim Young
Elevate Software
www.elevatesoft.com
« Previous PagePage 2 of 2
Jump to Page:  1 2
Image