Author |
Message |
gemisigo
Joined: 11 Mar 2010 Posts: 2165
|
|
[SA 7.5.496 Pro] - $OBJECT()$ macro bug |
|
It looks like a bug that had been disposed of ages ago crept back. Both versions, the one that inserts qualified name and the one that should only return the object name yields the item selected from the popup with schema name.
|
|
Thu Feb 25, 2016 10:53 am |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
|
|
Thank you very much for reporting this issue. I have logged it to our bug tracker.
|
|
Thu Feb 25, 2016 11:08 am |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
|
|
Are you using $OBJECT(ins_object)$ macro?
|
|
Thu Feb 25, 2016 11:38 am |
|
 |
gemisigo
Joined: 11 Mar 2010 Posts: 2165
|
|
|
|
No, I tried these:
 |
 |
$OBJECT(ins_schema, table, view)$
$OBJECT(ins_qualname, table, view)$
$OBJECT(table, view)$
|
They returned
 |
 |
dbo
dbo.my_table
dbo.my_table
|
I also tried
 |
 |
$OBJECT(ins_object, table, view)$
|
now that you mentioned it, and although it produces the desired
 |
 |
my_table
|
, it is not what the insert macro dialog inserts into editor (it pastes $OBJECT(table, view)$).
Making $OBJECT(table, view)$ non backward-compatible breaks several dozens of snippets. Was this change in behavior accidental or intentional?
|
|
Thu Feb 25, 2016 12:38 pm |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
|
|
I was told that the reversal to the original behavior was intentional because the mentioned fix was causing undesired side effects in several other places. To compensate for that a serious of additional options were added in 7.x releases to provide greater control over what's inserted int other code. But the dialog for $OBJECT(...)$ macro wasn't properly updated, resulting in some behavioral discrepancies. A fix for the dialog is in the works. In the case you described the dialog should have generated
 |
 |
$OBJECT(ins_object, table, view)$ |
in cases when only object name is required. If ins_.. options aren't explicitly selected, then the behavior is controlled by the state of SQL Assistance -> Auto Complete... -> Always Fully Qualify Object Names, which by default has a value of Only for objects in other schema or database
|
|
Fri Feb 26, 2016 2:14 am |
|
 |
gemisigo
Joined: 11 Mar 2010 Posts: 2165
|
|
|
|
Ahh, I see. That makes sense.
Are there any other ways to replace all the outdated $OBJECT()$ macros with their correct counterpart except for exporting settings to xml, search-replace and re-import it again? Perhaps you could incorporate that part (the search-replace) into update (and import) process so that it happens automatically when a settings file is imported or a new version is installed.
|
|
Fri Feb 26, 2016 4:02 am |
|
 |
gemisigo
Joined: 11 Mar 2010 Posts: 2165
|
|
|
|
Another issue. $OBJECT(ins_qualname, table, view)$ used to insert the object name with schema, that is, the result looked like
 |
 |
dbo.mytable
|
After the last update of 7.5.499 $OBJECT(ins_qualname, table, view)$ no longer qualifies the object with the schema alone but with the database name as well, resulting in
 |
 |
mydatabase.dbo.mytable
|
which has the undesired side-effect of completely ruining some of my custom made snippets.
I had the misconception that SA Options > DB Options > SQL Server > Auto Complete > Always Fully Qualify Object Names had some influence on this and I was obviously not entirely wrong assuming that because while it simply inserted the database.schema.object for both With schema name and With database and schema names, it actually made some difference setting it to With database and schema names, in which case even simple $OBJECT(table, view)$ macro results turned out to be 3-part qualified.
It looks as if $OBJECT(table, view)$ now behaves as $OBJECT(ins_qualname, table, view)$ had before, and $OBJECT(ins_qualname, table, view)$ yields a fully qualified objectname regardless of the setting mentioned above. Is this change in behavior by design? Are there any other changes to be expected? I already have a large number of snippets in inconsistent state because of the last change, I'd rather not add anything to that chaos :(
|
|
Thu Mar 17, 2016 10:43 am |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
|
|
I'm also under impressions that the following is incorrect
 |
 |
$OBJECT(ins_qualname, table, view)$ yields a fully qualified objectname regardless of the setting ... in SA Options > DB Options > SQL Server > Auto Complete > Always Fully Qualify Object Names. |
It might be caused by a side effect of some other changes.
I believe that setting should drive name qualification logic, the above behavior is not likely by design. I have logged a bug report.
|
|
Fri Mar 18, 2016 12:07 am |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
|
|
I have some clarifications for the previous post.
By design the 3-part name is supposed to be used for objects which are not in the current database. The tricky part here is treatment and meaning of "current" database. If in the object popup you select an object from database -> schema - object path, then it would insert 3-part name, it doesn't check if the selected database name equals the current database. You selected fully qualified name, you got it. But if you pick an object from schema -> object path, which is given for objects in the current database only, and the "Always Fully Qualify Object Names" settings don't require to always qualify with database name, then only schema qualification is supposed to be used.
|
|
Fri Mar 18, 2016 12:19 am |
|
 |
gemisigo
Joined: 11 Mar 2010 Posts: 2165
|
|
|
|
 |
 |
If in the object popup you select an object from database -> schema - object path, then it would insert 3-part name, it doesn't check if the selected database name equals the current database. You selected fully qualified name, you got it. |
That'd be fine as it'd be expected.
 |
 |
But if you pick an object from schema -> object path, which is given for objects in the current database only, and the "Always Fully Qualify Object Names" settings don't require to always qualify with database name, then only schema qualification is supposed to be used. |
Agreed. But that's not what happens, it puts the database name right in front of the schema name even if the object was schema.object picked from the popup.
Any hints on when this is going to be fixed? Almost 90% of my snippets are broken because of this.
|
|
Fri Mar 18, 2016 9:05 am |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
|
|
I was told that there is a fix available in the 8.0.xxx code branch, but that version is not yet stable. I have asked if we can and/or plan on back-porting that fix to 7.5.xxx branch, but didn't get their reply yet.
|
|
Fri Mar 18, 2016 9:20 am |
|
 |
gemisigo
Joined: 11 Mar 2010 Posts: 2165
|
|
|
|
Thank you very much. Eagerly awaiting then...
|
|
Fri Mar 18, 2016 9:53 am |
|
 |
gemisigo
Joined: 11 Mar 2010 Posts: 2165
|
|
|
|
What's the planned release date for 8.0?
|
|
Tue May 03, 2016 8:27 am |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
|
|
An early beta version is expected by the end of the month (end of May if all goes well).
|
|
Tue May 03, 2016 9:54 am |
|
 |
|