error on truncate()

0 views
Skip to first unread message

Tom McNeer

unread,
Sep 9, 2009, 2:58:12 PM9/9/09
to DataMgr
Hi,

I just downloaded the DataMgr package to test it, in particular the
truncate() feature, since I've run into the dreaded "string or binary
data will be truncated" error lately.

On my first run, attempting to insert a record into a table called
"Clients," I hit the following error: "Element Clients is undefined in
a CFML structure referenced as part of an expression.

In looking further, the error came from within the truncate() method,
and it occurs because getTableData() returns an empty struct. I can
run getDefaultValues() or getFieldLengths() on the table and get the
expected results. So I know I can hit the database.

But apparently, I'm missing a step where the tables get loaded into
variables.tables, since that's what getTableData() looks at.

Is there something I need to do after initializing the component
before I can call truncate()?

Thanks for your help.

Tom

Steve Bryant

unread,
Sep 10, 2009, 2:13:31 PM9/10/09
to dat...@googlegroups.com
Tom,

Congratulations, you found a bug!

You should be able to do exactly what you are doing, of course. What
is happening is that DataMgr doesn't know anything about the table.
The method should handle the discovery, but it isn't doing this. I'll
have the fix in 2.5, but in the meantime here are two possible
workarounds:

1. Open up DataMgr.cfc and add the following line just after <cfscript>:
var bTable = checkTable(arguments.tablename);//Check whether table is loaded

2. Call DataMgr.loadTable("Clients") before you call the truncate method.

Note, also, that the truncate method may result in a loss of data (its
purpose is to trim the excess, after all). If you leave that off,
DataMgr will give you a more helpful error. You may have already known
this, but it seemed a good idea to bring it up since we are discussing
truncate.

Sorry for the trouble, let me know how you get on from here.

Thanks,

Steve

Tom McNeer

unread,
Sep 11, 2009, 10:47:09 AM9/11/09
to dat...@googlegroups.com
Hi Steve,

On Thu, Sep 10, 2009 at 2:13 PM, Steve Bryant <sebt...@gmail.com> wrote:
Congratulations, you found a bug!


Well, that's good, I guess. I'm just so unfamiliar with DataMgr, I figured it was me.

Thanks for the workarounds. They seem to work fine.

Note, also, that the truncate method may result in a loss of data (its
purpose is to trim the excess, after all). If you leave that off,
DataMgr will give you a more helpful error. You may have already known
this, but it seemed a good idea to bring it up since we are discussing
truncate.

I appreciate your bringing it up, but I fully understand the ramifications.

At this point, it's the better option. I have a long, complex multi-part form that takes my client's customers a long time to fill out. And about twice a month, the submission fails with a "data will be truncated" error. I've made sure that all the string fields are way longer than could be necessary, but the error still recurs; and I still can't find the source(s).

I know that DataMgr can help me track this down, and I intend to use it for that purpose in the dev environment. But the real-world issue is that we need to prevent the error, because it's extremely frustrating for the customer. So truncating the data is a much, much better alternative right now.

Thanks for building a tool that will help eliminate this.


--
Thanks,

Tom

Tom McNeer
MediumCool
http://www.mediumcool.com
1735 Johnson Road NE
Atlanta, GA 30306
404.589.0560
Reply all
Reply to author
Forward
0 new messages