dropPrimaryKey without constraint name on sql server doesn't honour schema information

Description

I'm trying to drop a primary key from a table. The XML that I'm using in liquibase to accomplish that is:

1 <dropPrimaryKey tableName="MY_TABLE" />

The generated Query for SQL-Server looks like

1 2 3 4 5 DECLARE @pkname nvarchar(255) DECLARE @sql nvarchar(2048) select @pkname=i.name from sysindexes i join sysobjects o ON i.id = o.id join sysobjects pk ON i.name = pk.name AND pk.parent_obj = i.id AND pk.xtype = 'PK' join sysindexkeys ik on i.id = ik.id AND i.indid = ik.indid join syscolumns c ON ik.id = c.id AND ik.colid = c.colid where o.name = 'MY_TABLE' set @sql='alter table [dbo].[MY_TABLE] drop constraint ' + @pkname exec(@sql)

and what's missing is the schema condition. If it should support any Schemaname the Query should look like:

select @pkname=o.name
from sysindexes i
join sysobjects o ON i.id = o.id
join sysobjects pk ON i.name = pk.name
AND pk.parent_obj = i.id
AND pk.xtype = 'PK'
join sysindexkeys ik on i.id = ik.id
AND i.indid = ik.indid
join syscolumns c ON ik.id = c.id
AND ik.colid = c.colid

INNER JOIN sysusers su ON o.uid = su.uid

where o.name = 'MY_TABLE'

and su.name = 'MY_SCHEMA'

This Bug affects the following class only

liquibase.sqlgenerator.core.DropPrimaryKeyGenerator

Let me know if you need any more information.

Environment

SQL-Server

Status

Assignee

Unassigned

Reporter

Gilles Zimmermann

Labels

None

Components

Fix versions

Affects versions

3.2.3

Priority

Major