The magic column [tagname]
will decorate and auto link tag names when used in a query. This feature relies on the JavaScript processing in the browser. The client-side script assumes it will always get a string. Now try this query:
select id [tagname]
from votetypes
Id is an tinyint in SQL Server and becomes a JavaScript Number when the resultset is send over the wire.
The result is ... column headers only. Not a single row gets rendered. No errors in the UI. But that is a different story in the Developer Console of the browser.
In query.resultset.js the tagFormatter
does this:
if (!value || !(value.match(/^[a-z0-9#.+-]+$/) || (isMultiTags = (value.search(/^(?:<[a-z0-9#.+-]+>)+$/) > -1)))) {
return defaultFormatter(row, cell, value, column, context);
}
In the above snippet value
will be of type Number and unfortunately Number doesn't have methods named match
or search
so it will fail there with a
Uncaught TypeError: value.match is not a function
(in the minified version the variable name is different).
I guess that if
logic needs to include a typeof value !== 'string'
so it will for Number columns fallback to the default formatter as it does for other case where it can't workout if the field has a supported tag name.
The workaround is simple: Only use string value columns with the magic column [tagname]
to not break the client-side JavaScript.
This post is primarily meant to document the unexpected behavior. For a fix we wait for 6 to 8 weeks till soon™.
/regex/.test(value)
which doesn't access any properties ofvalue
.Number
prototype to add.match
and.search
methods that returnfalse
/a falsey value when called.[1984]
on Literature is a synonym to[nineteen-eighty-four]
.value
is not a string (and throw an error) or explicitly disallowed the use of magic columns with number-only columns. In any case, this seems like an uncaught error, which should be fixed (though it's not a high priority as rene mentioned).TypeError
or, worse,SyntaxError
, is by definition, a piece of code that has a bug. The bug is that the end user doesn't get any feedback that something went wrong in the first place. Instead,tagFormatter
happily trods along to process a type it is unprepared for (not to mention that other formatters have sanity checks for the correct type). Not sure why you insist this is not a bug - it's a textbook one (not an incredibly important one, but still).tagFormatter
factory gets called in the first place. Isn't it guarded by thecolumn.name.toLowerCase() === 'tags' || column.name.toLowerCase() === 'tagname'
condition?