1# 分布式数据管理子系统Changelog 2 3## cl.relationalStore.1 数据库插入长度为0的Uint8Array的数据,getRow、getValue 接口返回值发生变化 4 5**访问级别** 6 7公开接口 8 9**变更原因** 10 11当插入列类型是blob且数据为长度为0的Uint8Array时,数据库对应错误写入null值,导致使用getRow和getValue接口读取时,读取数值结果错误与插入数据不匹配。 12 13**变更影响** 14 15该变更为不兼容变更。 16 17变更前:在blob类型的列里插入长度为0的Uint8Array,调用getRow/getValue接口,获取到的值是null。 18 19变更后:在blob类型的列里插入长度为0的Uint8Array,调用getRow/getValue接口,获取到的值是长度为0的Uint8Array。 20 21**起始 API Level** 22 23| 接口名称 | 起始 API Level | 24| -------- | -------------- | 25| getRow | API 11 | 26| getValue | API 12 | 27 28**变更发生版本** 29 30从OpenHarmony SDK 5.0.0.46版本开始。 31 32**变更的接口/组件** 33 34@ohos.data.relationalStore.d.ts中getRow接口。 35@ohos.data.relationalStore.d.ts中getValue接口。 36 37**适配指导** 38 39变更后,接口的调用方式没有发生变化。开发者需要关注,在blob类型的列里插入长度为0的Uint8Array后,调用getRow或getValue获取到的值发生了变化。 40```ts 41import { relationalStore } from '@kit.ArkData'; 42import { BusinessError } from '@kit.BasicServicesKit'; 43import { UIAbility } from '@kit.AbilityKit'; 44import { window } from '@kit.ArkUI'; 45 46const STORE_CONFIG: relationalStore.StoreConfig = { 47 name: "RdbTest.db", 48 securityLevel: relationalStore.SecurityLevel.S3 49}; 50const CREATE_TABLE_TEST = 51 "CREATE TABLE IF NOT EXISTS EMPLOYEE (id INTEGER PRIMARY KEY AUTOINCREMENT,name TEXT NOT NULL, age INTEGER, salary REAL, blobType BLOB)"; 52 53let store: relationalStore.RdbStore | undefined = undefined; 54relationalStore.getRdbStore(this.context, STORE_CONFIG, (err: BusinessError, rdbStore: relationalStore.RdbStore) => { 55 store = rdbStore; 56 store.executeSql(CREATE_TABLE_TEST); 57 if (err) { 58 console.error(`Get RdbStore failed, code is ${err.code},message is ${err.message}`); 59 return; 60 } 61 console.info('Get RdbStore successfully.'); 62}) 63//在ValuesBucket的blob类型插入长度为0的Uint8Array,并查询该数据。 64let resultSet: relationalStore.ResultSet | undefined = undefined; 65let predicates = new relationalStore.RdbPredicates("EMPLOYEE"); 66if (store != undefined) { 67 (store as relationalStore.RdbStore).query(predicates).then((result: relationalStore.ResultSet) => { 68 resultSet = result; 69 }); 70} 71if (resultSet != undefined) { 72 //blobType是数据类型为blob的列名 73 const codes = (resultSet as relationalStore.ResultSet).getValue((resultSet as relationalStore.ResultSet).getColumnIndex("blobType")); 74} 75//变更前 codes为null。 76//变更后 codes为长度为0的Uint8Array。 77 78if (resultSet != undefined) { 79 const row = (resultSet as relationalStore.ResultSet).getRow(); 80} 81//变更前 row.blobType为null。 82//变更后 row.blobType为长度为0的Uint8Array。 83```