TABLES WITH COLUMNS HAVING " " IN THEIR NAME

1 view
Skip to first unread message

pandelis

unread,
Feb 17, 2010, 12:56:01 PM2/17/10
to CslaGenerator
Lets say for example i have a column that is called [TEST 1]. The
generator fails to create the proper object names or stored procedures
in such a case. i have a created a simple plugin that replaces the
name and friendly name of the column name with a firendly one. But if
i mess up the parameter field the stored procedures are a mess.

will that be fixed?

here is the code u need to add to create such a plugin urself. follow
the plugin example of andres for more questions.

Sub FIX_PROPS()
For Each obj As CslaObjectInfo In Unit.CslaObjects

For Each vProp As ValueProperty In obj.ValueProperties
vProp.Name = vProp.Name.Replace(" ", "_").Replace("-",
"_").Replace("(", "_").Replace(")", "_")
vProp.FriendlyName = vProp.Name
Next

Next
End Sub

Public Sub New()
AddCommand("FIX PROPERTIES", AddressOf FIX_PROPS)
End Sub

Andrés Villanueva

unread,
Feb 17, 2010, 1:45:57 PM2/17/10
to cslage...@googlegroups.com
What's the problem are you having with the parameters?




--
Andrés

pandelis

unread,
Feb 18, 2010, 1:43:03 AM2/18/10
to CslaGenerator
If u have a database with a column named [test 1] for example, and
want to create and editable root list, the default generator behaviour
is to get the name, firendlyname and parameter fields as [test 1]. The
generation of these objects doesnt compile of course cause the
properties have the blank in between. that is fixed with my plugin.
But the insert statement for example (when the parameter remains [test
1] and it should) creates the parameter [test 1] which cant run as a
stored procedure. If u change all the parameters names so as not to
have any blanks, then i believe either the fetch or the doinsertupdate
subroutine doesnt work cause some of the fields are wrong. I have
faced that problem about a few days ago and i dont remember which
proplem of the two (or both) i faced in the second case. In any case
the generator's result breaks in such cases where symbols or blanks
are included in these fields.

Andrés Villanueva

unread,
Feb 18, 2010, 7:33:28 AM2/18/10
to cslage...@googlegroups.com
I'll add this to my todo list and see what can be done. It might need a massive change so I can't promise anything. This is the first time I heard anybody using column names with spaces in cslagen and I don't think it's a common case, so it's low priority.
Thanks for the heads up!


--



--
Andrés

Q Johnson

unread,
Feb 18, 2010, 8:56:57 AM2/18/10
to cslage...@googlegroups.com
If you have control of the db, just eliminate the spaces and endure whatever
pain that leaves you. A decent code generator can certainly reproduce any
documentation written about it.

If you can't change the names, just change the templates to place the
offending (or all) column names in square brackets, rather than replacing
their spaces. So you would have code like "Select [text 1] from myTable"
which is perfectly acceptable SQL.

Won't these fairly pedestrian suggestions work in your case?

"Q" Johnson

--

Andrés Villanueva

unread,
Feb 18, 2010, 9:04:04 AM2/18/10
to cslage...@googlegroups.com
The generated sql does wrap column names between brackets, but the problem in this case aren't columns, but the generated variable names in the sprocs, which I believe can't have spaces.
Of course, if you can alter the tables to remove the spaces in those column names, that would be ideal.
--
Andrés

pandelis

unread,
Feb 19, 2010, 1:31:26 AM2/19/10
to CslaGenerator
Thank you andres,

These are not databases i can control, else i wouldnt have any
problem. But still with my plugin i eliminate most of the trouble.
Just refering the issue and giving a partial solution to any1 who
might have the same one.

Reply all
Reply to author
Forward
0 new messages