Use of Underscores

Colin Putney cputney at whistler.net
Fri Aug 23 20:35:53 UTC 2002


On Friday, August 23, 2002, at 12:54  PM, Chris Burkert wrote:

I only did a test if a connection in general is possible. It all ends in 
a 'key not found' of a Dictionary that holds the Result of the Query.

ResultSet>>valueNamed: aName
	^self valueAt: (columnsByName at: aName)

aName has the value 'foo_bar'. So I think, the Query was successful, but 
the creation of the Result-Dictionary with the correct name of the Row 
'foo_bar' isn't possible. I don't want to change something of the 
MySQL-Driver (I think we even had to change something in Dictionary) ... 
perhaps there is a possibility to 'code' the underscore but I don't have 
any idea.

In general, is it possible to use the underscore in names of keys of 
Dictionarys ? I don't think so ... why ? Isn't there any way to 'escape' 
it (... \_ ...) ?

Hmm. I did a similar test without any problems. Here's what I did. First 
I created a database using mysql monitor:

CREATE TABLE test (
   id int(11) default NULL,
   name_test varchar(15) default NULL
) TYPE=MyISAM;

INSERT INTO test VALUES (1,'aName');


Then I executed the following in a Workspace:


spec := JdmConnectionSpec new initialize.
spec
	database: 'TNTest';
	host: (NetNameResolver addressForName: 'trillian.whistler.com');
	user: 'tantalus';
	password: 'demo'.
conn := JdmConnection on: spec.

conn createStatement executeQuery: 'CREATE TABLE test (
   id int(11) default NULL,
   name_test varchar(15) default NULL
) TYPE=MyISAM'.

conn createStatement executeQuery: 'SELECT * FROM test'.

set := conn createStatement executeQuery: 'SELECT * FROM test'.
set next.
set valueAt: 2.
set valueNamed: 'name_test'


Both #valueAt: and #valueNamed: returned the correct result, 'aName'.

Now, I've been hacking on the MySQL-Driver a lot, and it's possible that 
I inadvertently fixed a bug.


Colin Putney
Whistler.com




More information about the Squeak-dev mailing list