You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
tsqlt.DropClass can't deal with some special characters in class names #5
I had trouble with using DropClass while trying to figure out some standardized naming conventions for Class (test schema) names. The issue is there when there is a dot (ASCII 46) in the name.
Looking at the code of the procedure I noticed that when it is looking for the schema id, it uses SCHEMA_ID(@classname) everywhere, expect where it looks up the schema itself from sys.schemas. There it is using SCHEMA_ID(PARSENAME(@classname,1)). Not sure what's the goal with this, but once there's a dot in the Class name, PARSENAME will keep only the part after it, and SCHEMA_ID will not find the schema.
I had trouble with using DropClass while trying to figure out some
standardized naming conventions for Class (test schema) names. The issue is
there when there is a dot (ASCII 46) in the name.
Looking at the code of the procedure I noticed that when it is looking for
the schema id, it uses SCHEMA_ID(@classname) everywhere, expect where it
looks up the schema itself from sys.schemas. There it is using
SCHEMA_ID(PARSENAME(@classname,1)). Not sure what's the goal with this, but
once there's a dot in the Class name, PARSENAME will keep only the part
after it, and SCHEMA_ID will not find the schema.
Try wrapping the schema name in [brackets]. That should take care of your problem. Thanks, Sebastian
Unfortunately that doesn't work either, I tried. That way SCHEMA_ID(PARSENAME(@classname,1)) works out, but SCHEMA_ID(@classname) doesn't. Therefore the procedure fails, as it will not find and drop the objects in the schema before trying to drop the schema itself. Unless the schema didn't have any objects in it, of course.
Any update on this? Would be nice to have this fixed, so that I wouldn't need to apply workarounds in my projects.
We plan to integrate tsqlt into our CI process soon, a fix before that would make it even more straightforward.
Activity
Removing PARSENAME from sys.schemas lookup
tSQLt-robot commentedon Jul 15, 2016
Try wrapping the schema name in [brackets]. That should take care of your
problem.
Thanks,
Sebastian
On Fri, Jul 15, 2016 at 4:28 PM, Prof-hu notifications@github.com wrote:
Prof-hu commentedon Jul 15, 2016
@tSQLt-robot
Unfortunately that doesn't work either, I tried. That way SCHEMA_ID(PARSENAME(@classname,1)) works out, but SCHEMA_ID(@classname) doesn't. Therefore the procedure fails, as it will not find and drop the objects in the schema before trying to drop the schema itself. Unless the schema didn't have any objects in it, of course.
mbt1 commentedon Jul 15, 2016
That is then a problem. I will look into it.
Prof-hu commentedon Jul 15, 2016
@mbt1
Thanks!
Adding PARSENAME to all SCHEMA_ID lookups
Prof-hu commentedon Sep 8, 2016
Any update on this? Would be nice to have this fixed, so that I wouldn't need to apply workarounds in my projects.
We plan to integrate tsqlt into our CI process soon, a fix before that would make it even more straightforward.