Pārlūkot izejas kodu

Fix coach identity on creation and projection refresh

彭峰 2 stundas atpakaļ
vecāks
revīzija
a6cc1c7864

+ 4 - 3
scripts/deploy-admin-functions.mjs

@@ -3810,7 +3810,7 @@ function coachPayload(payload,creating=false) { const username=text(payload.user
 async function createCoach(context,input,payload) {
   requireRole(context,['ops-manager']);const reason=reasonOf(input),data=coachPayload(payload,true),companyId=companyIdOf(context,input);if(!companyId)fail(400,'新增陪练必须指定帐套');const company=await new Parse.Query('Company').get(companyId,{useMasterKey:true});await coachStore(context,input,data.parentUserId);const duplicate=await Psql.oneOrNone('SELECT "objectId" FROM "_User" WHERE "company"=$1 AND "username"=$2 AND ("isDeleted" IS NULL OR "isDeleted"=FALSE) LIMIT 1',[companyId,data.username]);if(duplicate)fail(409,'此登录账号已被使用');
   const fields=await fieldsOf('_User'),created=new Parse.User();created.setUsername(data.username);created.setPassword(data.password);created.set('company',company);if(fields.type)created.set('type','user');if(fields.isDisabled)created.set('isDisabled',data.disabled);if(fields.isDeleted)created.set('isDeleted',false);if(fields.legacyGroupId)created.set('legacyGroupId',3);if(fields.nickname)created.set('nickname',data.displayName);if(fields.realName)created.set('realName',data.displayName);if(fields.mobile)created.set('mobile',data.mobile);if(fields.isAdmin)created.set('isAdmin',false);if(fields.roles)created.set('roles',[]);try{await created.signUp(null,{useMasterKey:true});}catch(error){if(number(error&&error.code)===202)fail(409,'此登录账号已被使用');fail(422,'陪练账号创建失败:'+text(error&&error.message));}
-  try{const legacy={UserID:0,UserName:data.username,HoneyName:data.displayName,GroupID:3,ParentUserID:data.parentUserId,VIP:0,RegTime:new Date().toISOString(),Purse:0,SilverCoin:0,UserExp:0,UserPoint:0,boffExp:0,State:data.disabled?0:1,OpsCreatedAt:new Date().toISOString()},rows=await Psql.query('WITH lock_row AS MATERIALIZED (SELECT pg_advisory_xact_lock(hashtext(\'xiaoshu-legacy-user-id\'))), next_id AS MATERIALIZED (SELECT COALESCE(MAX("legacyUserId"),0)+1 AS id FROM "_User",lock_row WHERE "company"=$1 AND COALESCE("legacyUserId",0)>0) UPDATE "_User" SET "legacyUserId"=next_id.id,"legacyGroupId"=3,"legacyUserData"=jsonb_set($3::jsonb,\'{UserID}\',to_jsonb(next_id.id),true),"updatedAt"=NOW() FROM next_id WHERE "objectId"=$2 RETURNING next_id.id',[companyId,created.id,JSON.stringify(legacy)]),userId=number(rows[0]&&rows[0].id);if(!userId)throw new Error('无法分配陪练业务 ID');await audit(context,'create-coach','_User',created.id,reason,null,{userId,username:data.username,displayName:data.displayName,parentUserId:data.parentUserId,disabled:data.disabled});return{objectId:created.id,userId};}catch(error){await created.destroy({useMasterKey:true}).catch(()=>undefined);if(error&&error.status)throw error;fail(422,'陪练业务资料初始化失败:'+text(error&&error.message));}
+  try{const legacy={UserID:0,UserName:data.username,HoneyName:data.displayName,GroupID:3,ParentUserID:data.parentUserId,VIP:0,RegTime:new Date().toISOString(),Purse:0,SilverCoin:0,UserExp:0,UserPoint:0,boffExp:0,State:data.disabled?0:1,OpsCreatedAt:new Date().toISOString()},rows=await Psql.query('WITH lock_row AS MATERIALIZED (SELECT pg_advisory_xact_lock(hashtext(\'xiaoshu-legacy-user-id\'))), next_id AS MATERIALIZED (SELECT COALESCE(MAX("legacyUserId"),0)+1 AS id FROM "_User",lock_row WHERE "company"=$1 AND COALESCE("legacyUserId",0)>0) UPDATE "_User" SET "legacyUserId"=next_id.id,"legacyGroupId"=3,"identityType"=\'coach\',"legacyUserData"=jsonb_set($3::jsonb,\'{UserID}\',to_jsonb(next_id.id),true),"updatedAt"=NOW() FROM next_id WHERE "objectId"=$2 RETURNING next_id.id',[companyId,created.id,JSON.stringify(legacy)]),userId=number(rows[0]&&rows[0].id);if(!userId)throw new Error('无法分配陪练业务 ID');await audit(context,'create-coach','_User',created.id,reason,null,{userId,username:data.username,displayName:data.displayName,parentUserId:data.parentUserId,disabled:data.disabled});return{objectId:created.id,userId};}catch(error){await created.destroy({useMasterKey:true}).catch(()=>undefined);if(error&&error.status)throw error;fail(422,'陪练业务资料初始化失败:'+text(error&&error.message));}
 }
 async function scopedCoachObject(context,input) { const objectId=text(input.targetId);if(!objectId)fail(400,'缺少陪练记录');const target=await new Parse.Query('_User').get(objectId,{useMasterKey:true}),companyId=companyIdOf(context,input),targetCompanyId=pointerId(target.get('company'));if(companyId&&targetCompanyId!==companyId)fail(404,'陪练不存在或不属于当前帐套');if(context.storeId)await storeAssertCoach(context,objectId,true);return target; }
 async function updateCoach(context,input,payload) {
@@ -4172,9 +4172,10 @@ async function pendingSyncDeadLetters(context,input,dataset,legacyKey){const que
 async function resolveSyncDeadLetters(context,input,dataset,legacyKey){const rows=await pendingSyncDeadLetters(context,input,dataset,legacyKey);if(!rows.length)return;for(const row of rows){row.set('resolved',true);row.set('resolvedAt',new Date());}await Parse.Object.saveAll(rows,{useMasterKey:true});}
 async function writeSyncDeadLetter(context,input,dataset,item,error){const existing=await pendingSyncDeadLetters(context,input,dataset,item.key),company=companyPointer(context,input),row=existing[0]||new Parse.Object('LegacySyncDeadLetter');if(!row.id){if(company)row.set('company',company);row.set('sourceKey','cloud:legacy-sync-dead:'+companyIdOf(context,input)+':'+dataset+':'+text(item.key));row.set('dataset',dataset);row.set('legacyKey',text(item.key));row.set('attempts',0);}row.set('recordClasses',(item.records||[]).map((record)=>text(record.className)));row.set('errorCode',number(error.status||error.code));row.set('errorMessage',text(error.message).slice(0,1000));row.increment('attempts',1);row.set('resolved',false);row.set('lastAttemptAt',new Date());await row.save(null,{useMasterKey:true});}
 async function refreshIdentityProjection(context,input){
+  // An account explicitly created as a coach does not need lessons to establish its role.
   // A confirmed coach can practise words; only actual student course evidence creates a dual-role conflict.
-  const companyId=companyIdOf(context,input),users=await Psql.query('SELECT "objectId",COALESCE(CAST("legacyUserId" AS text),"legacyUserData"->>\'UserID\') uid,COALESCE(CAST("legacyGroupId" AS text),"legacyUserData"->>\'GroupID\') gid,COALESCE("isAdmin",FALSE) admin FROM "_User" WHERE ($1::text IS NULL OR "company"=$1) AND ("isDeleted" IS NULL OR "isDeleted"=FALSE)',[companyId]),coachRows=await Psql.query('SELECT DISTINCT uid FROM (SELECT NULLIF(CAST("pl" AS text),\'\') uid FROM "CourseAppointment" WHERE ($1::text IS NULL OR "company"=$1) UNION SELECT NULLIF(CAST("fxpl" AS text),\'\') FROM "CourseAppointment" WHERE ($1::text IS NULL OR "company"=$1) UNION SELECT NULLIF(CAST("jsmz" AS text),\'\') FROM "LessonRecord" WHERE ($1::text IS NULL OR "company"=$1)) x WHERE uid IS NOT NULL',[companyId]),studentRows=await Psql.query('SELECT uid,bool_or(formal) AS formal FROM (SELECT NULLIF(CAST("szyh" AS text),\'\') uid,true AS formal FROM "CourseAppointment" WHERE ($1::text IS NULL OR "company"=$1) UNION ALL SELECT NULLIF(CAST("userId" AS text),\'\'),true FROM "DailyStudyRecord" WHERE ($1::text IS NULL OR "company"=$1) UNION ALL SELECT NULLIF(CAST("yhid" AS text),\'\'),true FROM "CourseBinding" WHERE ($1::text IS NULL OR "company"=$1) UNION ALL SELECT NULLIF(CAST("xymz" AS text),\'\'),true FROM "LessonRecord" WHERE ($1::text IS NULL OR "company"=$1) UNION ALL SELECT NULLIF(CAST("yhid" AS text),\'\'),false FROM "PracticeRecord" WHERE ($1::text IS NULL OR "company"=$1)) x WHERE uid IS NOT NULL GROUP BY uid',[companyId]),coachIds=new Set(coachRows.map((row)=>text(row.uid))),studentIds=new Set(studentRows.map((row)=>text(row.uid))),formalStudentIds=new Set(studentRows.filter((row)=>row.formal===true).map((row)=>text(row.uid)));let conflicts=0;
-  for(const row of users){if(row.admin===true)continue;const uid=text(row.uid),gid=number(row.gid),coach=coachIds.has(uid),student=studentIds.has(uid),identity=gid===2?'store':coach&&student&&(gid!==3||formalStudentIds.has(uid))?'conflict':coach?'coach':student||gid===1?'member':'unknown',target=await new Parse.Query('_User').get(text(row.objectId),{useMasterKey:true});if(text(target.get('identityType'))!==identity){target.set('identityType',identity);await target.save(null,{useMasterKey:true});}if(identity==='conflict'){conflicts++;const existing=await Psql.oneOrNone('SELECT "objectId" FROM "LegacySyncConflict" WHERE "company"=$1 AND "dataset"=\'users\' AND "legacyKey"=$2 AND COALESCE("resolved",FALSE)=FALSE LIMIT 1',[companyId,uid]).catch(()=>null);if(!existing){const issue=new Parse.Object('LegacySyncConflict');issue.set('company',companyPointer(context,input));issue.set('sourceKey','cloud:legacy-sync-conflict:'+companyId+':user:'+uid);issue.set('dataset','users');issue.set('legacyKey',uid);issue.set('conflictType','identity');issue.set('message','账号同时出现在学员和陪练业务字段中');issue.set('resolved',false);await issue.save(null,{useMasterKey:true});}}}
+  const companyId=companyIdOf(context,input),users=await Psql.query('SELECT "objectId",COALESCE(CAST("legacyUserId" AS text),"legacyUserData"->>\'UserID\') uid,COALESCE(CAST("legacyGroupId" AS text),"legacyUserData"->>\'GroupID\') gid,COALESCE("isAdmin",FALSE) admin,("legacyGroupId"=3 AND "legacyUserId">0 AND "legacyUserData"->>\'UserID\'="legacyUserId"::text AND "legacyUserData"->>\'GroupID\'=\'3\' AND COALESCE("legacyUserData"->>\'OpsCreatedAt\',\'\')<>\'\') AS "opsCreatedCoach" FROM "_User" WHERE ($1::text IS NULL OR "company"=$1) AND ("isDeleted" IS NULL OR "isDeleted"=FALSE)',[companyId]),coachRows=await Psql.query('SELECT DISTINCT uid FROM (SELECT NULLIF(CAST("pl" AS text),\'\') uid FROM "CourseAppointment" WHERE ($1::text IS NULL OR "company"=$1) UNION SELECT NULLIF(CAST("fxpl" AS text),\'\') FROM "CourseAppointment" WHERE ($1::text IS NULL OR "company"=$1) UNION SELECT NULLIF(CAST("jsmz" AS text),\'\') FROM "LessonRecord" WHERE ($1::text IS NULL OR "company"=$1)) x WHERE uid IS NOT NULL',[companyId]),studentRows=await Psql.query('SELECT uid,bool_or(formal) AS formal FROM (SELECT NULLIF(CAST("szyh" AS text),\'\') uid,true AS formal FROM "CourseAppointment" WHERE ($1::text IS NULL OR "company"=$1) UNION ALL SELECT NULLIF(CAST("userId" AS text),\'\'),true FROM "DailyStudyRecord" WHERE ($1::text IS NULL OR "company"=$1) UNION ALL SELECT NULLIF(CAST("yhid" AS text),\'\'),true FROM "CourseBinding" WHERE ($1::text IS NULL OR "company"=$1) UNION ALL SELECT NULLIF(CAST("xymz" AS text),\'\'),true FROM "LessonRecord" WHERE ($1::text IS NULL OR "company"=$1) UNION ALL SELECT NULLIF(CAST("yhid" AS text),\'\'),false FROM "PracticeRecord" WHERE ($1::text IS NULL OR "company"=$1)) x WHERE uid IS NOT NULL GROUP BY uid',[companyId]),coachIds=new Set(coachRows.map((row)=>text(row.uid))),studentIds=new Set(studentRows.map((row)=>text(row.uid))),formalStudentIds=new Set(studentRows.filter((row)=>row.formal===true).map((row)=>text(row.uid)));let conflicts=0;
+  for(const row of users){if(row.admin===true)continue;const uid=text(row.uid),gid=number(row.gid),coach=row.opsCreatedCoach===true||coachIds.has(uid),student=studentIds.has(uid),identity=gid===2?'store':coach&&student&&(gid!==3||formalStudentIds.has(uid))?'conflict':coach?'coach':student||gid===1?'member':'unknown',target=await new Parse.Query('_User').get(text(row.objectId),{useMasterKey:true});if(text(target.get('identityType'))!==identity){target.set('identityType',identity);await target.save(null,{useMasterKey:true});}if(identity==='conflict'){conflicts++;const existing=await Psql.oneOrNone('SELECT "objectId" FROM "LegacySyncConflict" WHERE "company"=$1 AND "dataset"=\'users\' AND "legacyKey"=$2 AND COALESCE("resolved",FALSE)=FALSE LIMIT 1',[companyId,uid]).catch(()=>null);if(!existing){const issue=new Parse.Object('LegacySyncConflict');issue.set('company',companyPointer(context,input));issue.set('sourceKey','cloud:legacy-sync-conflict:'+companyId+':user:'+uid);issue.set('dataset','users');issue.set('legacyKey',uid);issue.set('conflictType','identity');issue.set('message','账号同时出现在学员和陪练业务字段中');issue.set('resolved',false);await issue.save(null,{useMasterKey:true});}}}
   return conflicts;
 }
 async function runSyncPage(context,input,internalAuthorized=false){

+ 27 - 0
scripts/sql/repair-ops-coach-identity.sql

@@ -0,0 +1,27 @@
+-- Pass the affected company ID as $1. Only restore accounts created as coaches
+-- by the operations gateway that do not have formal student records.
+UPDATE "_User" u
+SET "identityType" = 'coach', "updatedAt" = now()
+WHERE u.company = $1
+  AND u."legacyGroupId" = 3
+  AND u."legacyUserId" > 0
+  AND u."legacyUserData"->>'UserID' = u."legacyUserId"::text
+  AND u."legacyUserData"->>'GroupID' = '3'
+  AND COALESCE(u."legacyUserData"->>'OpsCreatedAt', '') <> ''
+  AND COALESCE(u."identityType", '') IN ('', 'unknown', 'member')
+  AND NOT COALESCE(u."isAdmin", false)
+  AND NOT COALESCE(u."isDeleted", false)
+  AND NOT EXISTS (
+    SELECT 1 FROM "CourseAppointment" a
+    WHERE a.company = u.company AND a.szyh::text = u."legacyUserId"::text
+    UNION ALL
+    SELECT 1 FROM "DailyStudyRecord" d
+    WHERE d.company = u.company AND d."userId"::text = u."legacyUserId"::text
+    UNION ALL
+    SELECT 1 FROM "CourseBinding" b
+    WHERE b.company = u.company AND b.yhid::text = u."legacyUserId"::text
+    UNION ALL
+    SELECT 1 FROM "LessonRecord" l
+    WHERE l.company = u.company AND l.xymz::text = u."legacyUserId"::text
+  )
+RETURNING u."objectId", u."legacyUserId";

+ 70 - 8
scripts/tests/coach-identity-projection.test.mjs

@@ -15,10 +15,17 @@ gateway.Psql = {
   query: async (sql, args) => (await db.query(sql, args)).rows,
   oneOrNone: async (sql, args) => (await db.query(sql, args)).rows[0] || null,
 };
+gateway.fieldsOf = async () => ({ realName: true, isDisabled: true });
+gateway.audit = async () => {};
+gateway.availabilityRows = async () => [];
+gateway.operationalSyncIndicator = async () => ({});
+gateway.realtimeCacheWrite = async () => {};
 // Parse is external; SQL evidence queries and persisted identity changes use the real database.
 gateway.Parse = {
   Query: class {
+    constructor(className) { this.className = className; }
     async get(id) {
+      if (this.className === 'Company') return { id };
       const row = (await db.query('SELECT * FROM "_User" WHERE "objectId"=$1', [id])).rows[0];
       return {
         get: key => row[key], set: (key, value) => { row[key] = value; },
@@ -26,27 +33,43 @@ gateway.Parse = {
       };
     }
   },
+  User: class {
+    id = 'new-coach';
+    fields = {};
+    set(key, value) { this.fields[key] = value; }
+    setUsername(value) { this.set('username', value); }
+    setPassword() {}
+    async signUp() {
+      const { company, username, realName, isDisabled } = this.fields;
+      await db.query('INSERT INTO "_User" ("objectId",company,username,"realName","isDisabled") VALUES ($1,$2,$3,$4,$5)',
+        [this.id, company.id, username, realName ?? null, isDisabled ?? null]);
+    }
+    async destroy() { await db.query('DELETE FROM "_User" WHERE "objectId"=$1', [this.id]); }
+  },
   Object: class { set() {} async save() {} },
 };
 before(async () => {
   await db.exec(`
-    CREATE TABLE "_User"("objectId" text,company text,"legacyUserId" int,"legacyGroupId" int,"legacyUserData" jsonb,"isAdmin" boolean,"isDeleted" boolean,"identityType" text);
-    CREATE TABLE "CourseAppointment"(company text,pl text,fxpl text,szyh text);
-    CREATE TABLE "LessonRecord"(company text,jsmz text,xymz text);
+    CREATE TABLE "_User"("objectId" text,company text,"legacyUserId" int,"legacyGroupId" int,"legacyUserData" jsonb,"isAdmin" boolean,"isDeleted" boolean,"identityType" text,username text,"realName" text,nickname text,"isDisabled" boolean,"createdAt" timestamptz DEFAULT now(),"updatedAt" timestamptz DEFAULT now());
+    CREATE TABLE "CourseAppointment"(company text,pl text,fxpl text,szyh text,yysj text,bxrq text,dszt text,id int,jssj text);
+    CREATE TABLE "LessonRecord"(company text,jsmz text,xymz text,kclx text,pf text,plpjsj text,"lessonAt" text,id int,yyds text);
+    CREATE TABLE "CommonModel"(company text,"modelId" int,"itemId" int,"generalId" int,"createdAt" timestamptz);
     CREATE TABLE "DailyStudyRecord"(company text,"userId" int);
     CREATE TABLE "CourseBinding"(company text,yhid text);
     CREATE TABLE "PracticeRecord"(company text,yhid text);
     CREATE TABLE "LegacySyncConflict"("objectId" text,company text,dataset text,"legacyKey" text,resolved boolean);
-    INSERT INTO "_User" VALUES
+    INSERT INTO "_User" ("objectId",company,"legacyUserId","legacyGroupId","legacyUserData","isAdmin","isDeleted","identityType") VALUES
       ('teacher','co',1535,3,'{}',false,false,'conflict'),
       ('student','co',2,1,'{}',false,false,'member'),
       ('ambiguous','co',3,1,'{}',false,false,'conflict'),
       ('dual-binding','co',4,3,'{}',false,false,'conflict'),
       ('dual-lesson','co',5,3,'{}',false,false,'conflict'),
-      ('store','co',6,2,'{}',false,false,'store');
-    INSERT INTO "CourseAppointment" VALUES ('co','1535','1535','99'),('co','3',null,'99'),('co','4',null,'99'),('co','6',null,'6'),('other','99',null,'1535');
-    INSERT INTO "LessonRecord" VALUES ('co','5','5');
-    INSERT INTO "CourseBinding" VALUES ('co','4');
+      ('store','co',6,2,'{}',false,false,'store'),
+      ('native-both','co',7,3,'{"UserID":7,"GroupID":3,"OpsCreatedAt":"2026-11-27T00:00:00.000Z"}',false,false,'coach'),
+      ('legacy-unproven','co',8,3,'{}',false,false,'unknown');
+    INSERT INTO "CourseAppointment" (company,pl,fxpl,szyh) VALUES ('co','1535','1535','99'),('co','3',null,'99'),('co','4',null,'99'),('co','6',null,'6'),('other','99',null,'1535');
+    INSERT INTO "LessonRecord" (company,jsmz,xymz) VALUES ('co','5','5');
+    INSERT INTO "CourseBinding" VALUES ('co','4'),('co','7');
     INSERT INTO "PracticeRecord" VALUES ('co','1535'),('co','2'),('co','3');
   `);
   await gateway.refreshIdentityProjection({}, {});
@@ -68,3 +91,42 @@ test('老师同时有正式学员课程或课后记录时仍保留冲突,门
   assert.equal(await identity('dual-lesson'), 'conflict');
   assert.equal(await identity('store'), 'store');
 });
+
+const manager = { roles: ['ops-manager'] };
+const snapshot = { appointments: [], live: { allItems: [] } };
+const payroll = { coachItems: [], sourceStatus: {} };
+const searchCoaches = search => gateway.professionalCoachRows(manager, { search, refresh: true }, snapshot, payroll);
+
+test('后台新增陪练后没有排课记录也能立即按姓名搜索,并在重建身份后仍可见', async () => {
+  const created = await gateway.createCoach(manager, { reason: '创建测试老师' }, {
+    username: 'coach_without_lessons', displayName: '零课次陪练', password: 'test-password',
+  });
+  const found = await searchCoaches('零课次');
+  assert.equal(found.total, 1);
+  assert.equal(found.items[0].objectId, created.objectId);
+  assert.equal(found.items[0].monthLessons, 0);
+  assert.equal((await gateway.userByLegacyId(manager, {}, created.userId, 3)).identityType, 'coach');
+  await gateway.refreshIdentityProjection({}, {});
+  assert.equal((await searchCoaches('coach_without_lessons')).items[0].userId, created.userId);
+  assert.equal(await identity('native-both'), 'conflict');
+  assert.equal(await identity('legacy-unproven'), 'unknown');
+});
+
+test('补录只恢复本帐套后台创建且缺少正确身份的原账号,重复执行无额外更新', async () => {
+  await db.exec(`
+    INSERT INTO "_User" ("objectId",company,"legacyUserId","legacyGroupId","legacyUserData","isAdmin","isDeleted","identityType",username) VALUES
+      ('missing','co',21,3,'{"UserID":21,"GroupID":3,"HoneyName":"漏标陪练","OpsCreatedAt":"2026-11-27T00:00:00.000Z"}',false,false,null,'existing_coach'),
+      ('practice-only','co',22,3,'{"UserID":22,"GroupID":3,"OpsCreatedAt":"2026-11-27T00:00:00.000Z"}',false,false,'member','practising_coach'),
+      ('student-evidence','co',23,3,'{"UserID":23,"GroupID":3,"OpsCreatedAt":"2026-11-27T00:00:00.000Z"}',false,false,'unknown','student_evidence'),
+      ('deleted','co',24,3,'{"UserID":24,"GroupID":3,"OpsCreatedAt":"2026-11-27T00:00:00.000Z"}',false,true,'unknown','deleted_coach'),
+      ('other-tenant','other',25,3,'{"UserID":25,"GroupID":3,"OpsCreatedAt":"2026-11-27T00:00:00.000Z"}',false,false,null,'other_coach');
+    INSERT INTO "PracticeRecord" VALUES ('co','22');
+    INSERT INTO "CourseBinding" VALUES ('co','23'),('other','21');
+  `);
+  assert.equal((await searchCoaches('漏标陪练')).total, 0);
+  const sql = readFileSync(new URL('../sql/repair-ops-coach-identity.sql', import.meta.url), 'utf8');
+  const result = await db.query(sql, ['co']);
+  assert.deepEqual(result.rows.map(row => row.objectId).sort(), ['missing', 'practice-only']);
+  assert.equal((await searchCoaches('漏标陪练')).items[0].userId, 21);
+  assert.equal((await db.query(sql, ['co'])).rows.length, 0);
+});