Skip to content

tsqlt.DropClass can't deal with some special characters in class names #5

Open

Description

@Prof-hu

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.

Activity

  1. tSQLt-robot commented on Jul 15, 2016

    @tSQLt-robot
    Collaborator

    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:

    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.

    —
    You are receiving this because you are subscribed to this thread.
    Reply to this email directly, view it on GitHub
    #5, or mute the thread
    https://github.com/notifications/unsubscribe-auth/ANR4Kku3UykmF1Ns82eIZGMkHoy69ccpks5qV-1ygaJpZM4JNwdx
    .

  2. Prof-hu commented on Jul 15, 2016

    @Prof-hu
    Author

    @tSQLt-robot

    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.

  3. mbt1 commented on Jul 15, 2016

    @mbt1
    Collaborator

    That is then a problem. I will look into it.

  4. reopened this on Jul 15, 2016
  5. Prof-hu commented on Jul 15, 2016

    @Prof-hu
    Author

    @mbt1

    That is then a problem. I will look into it.

    Thanks!

  6. Prof-hu commented on Sep 8, 2016

    @Prof-hu
    Author

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions