File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -17,8 +17,8 @@ import {
1717 testTransaction ,
1818 typeORMGetBooks ,
1919 typeORMInit ,
20+ executeFailingTypeORMQuery ,
2021} from './Database' ;
21- // import { typeORMInit } from './Database';
2222import type { User } from './model/User' ;
2323import { Buffer } from 'buffer' ;
2424
@@ -30,11 +30,9 @@ export default function App() {
3030 // const users = queryUsers();
3131 // setUsers(users);
3232 typeORMInit ( ) . then ( ( ) => {
33- console . warn ( 'db initialized' ) ;
3433 typeORMGetBooks ( ) . then ( ( books ) => {
35- console . warn ( 'typeORM books' , books ) ;
36-
37- } )
34+ // console.warn('typeORM books', books);
35+ } ) ;
3836 } ) ;
3937 } , [ ] ) ;
4038
@@ -62,6 +60,10 @@ export default function App() {
6260 testTransaction ( ) ;
6361 } }
6462 />
63+ < Button
64+ title = "Execute typeORM failing query"
65+ onPress = { executeFailingTypeORMQuery }
66+ />
6567 < FlatList
6668 data = { users }
6769 renderItem = { ( { item } : ListRenderItemInfo < User > ) => {
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import { DataSource } from 'typeorm';
44import { Book } from './model/Book' ;
55import { User } from './model/User' ;
66// import { Buffer } from 'buffer';
7- let datasource : DataSource
7+ let datasource : DataSource ;
88
99export const lowLevelInit = ( ) => {
1010 // Start by opening a connection
@@ -86,11 +86,10 @@ export async function typeORMInit() {
8686 database : 'test2' ,
8787 location : '.' ,
8888 entities : [ Book ] ,
89- synchronize : true
89+ synchronize : true ,
9090 } ) ;
9191
92- await datasource . initialize ( )
93-
92+ await datasource . initialize ( ) ;
9493
9594 // await createConnection({
9695 // type: 'react-native',
@@ -129,5 +128,17 @@ export async function typeORMInit() {
129128
130129export async function typeORMGetBooks ( ) {
131130 const bookRepository = datasource . getRepository ( Book ) ;
132- return await bookRepository . find ( )
133- }
131+ return await bookRepository . find ( ) ;
132+ }
133+
134+ export async function executeFailingTypeORMQuery ( ) {
135+ const bookRepository = datasource . getRepository ( Book ) ;
136+
137+ try {
138+ const manualQuery = await bookRepository . query ( `
139+ SELECT * From UnexistingTable
140+ ` ) ;
141+ } catch ( e ) {
142+ console . warn ( 'should have cached' ) ;
143+ }
144+ }
Original file line number Diff line number Diff line change @@ -359,7 +359,12 @@ export const openDatabase = (
359359 try {
360360 let response = sqlite . executeSql ( options . name , sql , params ) ;
361361 enhanceQueryResult ( response ) ;
362- ok ( response ) ;
362+
363+ if ( response . status === 1 ) {
364+ fail ( response . message ) ;
365+ } else {
366+ ok ( response ) ;
367+ }
363368 } catch ( e ) {
364369 fail ( e ) ;
365370 }
You can’t perform that action at this time.
0 commit comments