 |
Anaristos Sorcerer
Joined: 17 Jul 2007 Posts: 821 Location: California
|
Posted: Fri Jun 18, 2010 1:02 am
[319fB] A peculiarity between db records and stringlists. |
I have modified my data provider to emit db records in the correct format. It works fine as far as I can tell.
However, I've run into a peculiarity. If the record consists of only one row, then encasing it double-quotes makes it unreadble at this end as a db record, instead it is turned into a stringlist. If I remove the double-quotes before I send the record then it works fine. Experimenting with %list shows that a stringlist of multiple database records is encased in double-quotes, but a db record consisting of a single row (a standard db record) is not. While I can understand why this is the case (i.e. the double-quotes are not necessary), it should still treat the adorned entry correctly. That is, it should realize that since it is encased in double-quotes, it is a db record.
Put another way, a single row record (a plain vanilla db record) may not be encased in double-quotes, even though it contains what could be construed as one or more stringlist separators. How CMUD determines that it is a db record rather than a string list, I cannot yet figure out, but it does. So
| Code: |
"key1=val1|key2=val2|.....|keyN=valN"
|
gets turned into a stringlist while
| Code: |
key1=val1|key2=val2|.....|keyN=valN
|
gets turned into a db record.
Now, this is no big deal, I can test, and am currently testing, for single-row emissions and adjusting the string accordingly. It does seem rather kludgy to me, though. So I am hoping that it is that I am doing something wrong.
EDIT: Here is another peculiarity...
| Code: |
$rec = @comcon.Execute($sql1, @noparam)
;;
conntab = %list( $rec)
|
works fine, but:
| Code: |
conntab = %list( @comcon.Execute($sql1, @noparam))
|
gets a far-side exception. (The parameter is incorrect)
The reason I say it is odd is becauase
| Code: |
#ADDKEY defvtab @comcon.Execute($sql2, @noparam)
|
works, so it is not a problem of using the raw COM object emission as a input to a function or command that is the problem.
I case you are wondering, @noparam is a an empty %array().
I must say this is not native to 319fB. I've experienced this problem in other versions. |
|
_________________ Sic itur ad astra. |
|
|
 |
Zugg MASTER

Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Fri Jun 18, 2010 2:23 am |
What you see is correct. Without the quotes it gets treated as a plain database variable. You need to enclose it in quotes to create a one-element string list that contains the database variables as a nested value.
The issue with %list is probably just because %list is new and hasn't been fully debugged. I'll add that issue to the list. |
|
|
|
 |
Anaristos Sorcerer
Joined: 17 Jul 2007 Posts: 821 Location: California
|
Posted: Fri Jun 18, 2010 2:40 am |
Yes, I understand that a string with quotes around should be interpreted as a string list with a nested db record. But that is not what I am getting. The encased db record is turned into a string list instead. So if I have 2 db records they are put into a string list correctly. But one single db record with quotes around it is converted to a string list instead of a string list consisting of a single db record.
|
|
_________________ Sic itur ad astra. |
|
|
 |
Zugg MASTER

Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Fri Jun 18, 2010 3:01 am |
Oh, ok, I misunderstood.
Yes, I can confirm this. However, I can't change it. The problem is that doing something like this:
#VAR db "key1=val1|key2=val2|.....|keyN=valN"
needs to create a Database variable and NOT a string list for backwards compatibility. Yes, backwards compatibility is a bitch. To accomplish what you want, you might need to add another set of doubled quotes (for a total of 3 " quote marks at each end of the string).
Or stick with using the JSON format which is more standarized and not subject to all of these backward compatibility kludges. |
|
|
|
 |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|