Chapel CDO ライブラリを使用して Postgres から配列をプルすると、エラーが発生し ます。次の表の pg インスタンスがあります。
DROP TABLE IF EXISTS aagg;
CREATE TABLE aagg (team text, name text);
INSERT INTO aagg VALUES ('Wonder Pets', 'Linny');
INSERT INTO aagg VALUES ('Wonder Pets', 'Ming Ming');
INSERT INTO aagg VALUES ('Wonder Pets', 'Tuck');
INSERT INTO aagg VALUES ('OJ Defense Team', 'F. Lee Bailey');
INSERT INTO aagg VALUES ('OJ Defense Team', 'Robert Shapiro');
INSERT INTO aagg VALUES ('OJ Defense Team', 'Johnny Cohchran');
以下のチャペルプログラムで引っ張ろうとしています
use Postgres;
config const DB_HOST: string = "localhost";
config const DB_USER: string = "buddha";
config const DB_NAME: string = "buddha";
config const DB_PWD: string = "buddha";
var con = PgConnectionFactory(host=DB_HOST, user=DB_USER, database=DB_NAME, passwd=DB_PWD);
var cursor = con.cursor();
// Retrieve the data
const q = "SELECT team, array_agg(name) AS members FROM aagg GROUP BY team;";
cursor.query(q);
for row in cursor {
writeln("Team: ", row['name'], "\tMembers: ", row['members'] );
for member in row['members'] {
writeln ("Special mention to ", member);
}
}
しかし、ループは次のように文字を分割します
Special mention to {
Special mention to "
Special mention to F
Special mention to .
Special mention to
Special mention to L
Special mention to e
Special mention to e
Special mention to
Special mention to B
Special mention to a
Special mention to i
Special mention to l
Special mention to e
Special mention to y
Special mention to "
これを配列に認識させるにはどうすればよいですか? ありがとう!