From 611000cde5c34badbd23b6ac6c9701bd7d9e287d Mon Sep 17 00:00:00 2001 From: danylo-safonov-solid <116712879+danylo-safonov-solid@users.noreply.github.com> Date: Wed, 20 Sep 2023 18:13:42 +0300 Subject: [PATCH] Notice (#16) * init * upd * init --- example/lib/main.dart | 1 + lib/src/notice.dart | 98 +++++++++++++++++++++++++++++++++++++++ lib/src/query_result.dart | 4 ++ 3 files changed, 103 insertions(+) create mode 100644 lib/src/notice.dart diff --git a/example/lib/main.dart b/example/lib/main.dart index 3ac3c71..a837448 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -19,6 +19,7 @@ Future fetch(Request _) async { return Response( [ result.command == CommandType.select, + 'warnings = ${result.warnings}', ''' rowDescription = columnCount = ${result.rowDescription?.columnCount} diff --git a/lib/src/notice.dart b/lib/src/notice.dart new file mode 100644 index 0000000..a1579ef --- /dev/null +++ b/lib/src/notice.dart @@ -0,0 +1,98 @@ +import 'dart:js_interop'; +import 'dart:js_util'; + +/// [postgres@v0.17.0/Notice](https://deno.land/x/postgres@v0.17.0/connection/message.ts?s=Notice). +@JS() +class Notice { + /// [postgres@v0.17.0/Notice/severity](https://deno.land/x/postgres@v0.17.0/connection/message.ts?s=Notice#prop_severity). + external String get severity; + + /// [postgres@v0.17.0/Notice/code](https://deno.land/x/postgres@v0.17.0/connection/message.ts?s=Notice#prop_code). + external String get code; + + /// [postgres@v0.17.0/Notice/message](https://deno.land/x/postgres@v0.17.0/connection/message.ts?s=Notice#prop_message). + external String get message; + + /// [postgres@v0.17.0/Notice/detail](https://deno.land/x/postgres@v0.17.0/connection/message.ts?s=Notice#prop_detail). + external String? get detail; + + /// [postgres@v0.17.0/Notice/hint](https://deno.land/x/postgres@v0.17.0/connection/message.ts?s=Notice#prop_hint). + external String? get hint; + + /// [postgres@v0.17.0/Notice/position](https://deno.land/x/postgres@v0.17.0/connection/message.ts?s=Notice#prop_position). + external String? get position; + + /// [postgres@v0.17.0/Notice/internalPosition](https://deno.land/x/postgres@v0.17.0/connection/message.ts?s=Notice#prop_internalPosition). + external String? get internalPosition; + + /// [postgres@v0.17.0/Notice/internalQuery](https://deno.land/x/postgres@v0.17.0/connection/message.ts?s=Notice#prop_internalQuery). + external String? get internalQuery; + + /// [postgres@v0.17.0/Notice/where](https://deno.land/x/postgres@v0.17.0/connection/message.ts?s=Notice#prop_where). + external String? get where; + + /// [postgres@v0.17.0/Notice/schema](https://deno.land/x/postgres@v0.17.0/connection/message.ts?s=Notice#prop_schema). + external String? get schema; + + /// [postgres@v0.17.0/Notice/table](https://deno.land/x/postgres@v0.17.0/connection/message.ts?s=Notice#prop_table). + external String? get table; + + /// [postgres@v0.17.0/Notice/column](https://deno.land/x/postgres@v0.17.0/connection/message.ts?s=Notice#prop_column). + external String? get column; + + /// [postgres@v0.17.0/Notice/dataType](https://deno.land/x/postgres@v0.17.0/connection/message.ts?s=Notice#prop_dataType). + external String? get dataType; + + /// [postgres@v0.17.0/Notice/constraint](https://deno.land/x/postgres@v0.17.0/connection/message.ts?s=Notice#prop_constraint). + external String? get constraint; + + /// [postgres@v0.17.0/Notice/file](https://deno.land/x/postgres@v0.17.0/connection/message.ts?s=Notice#prop_file). + external String? get file; + + /// [postgres@v0.17.0/Notice/line](https://deno.land/x/postgres@v0.17.0/connection/message.ts?s=Notice#prop_line). + external String? get line; + + /// [postgres@v0.17.0/Notice/routine](https://deno.land/x/postgres@v0.17.0/connection/message.ts?s=Notice#prop_routine). + external String? get routine; + + /// [postgres@v0.17.0/Notice](https://deno.land/x/postgres@v0.17.0/connection/message.ts?s=Notice). + factory Notice({ + required String severity, + required String code, + required String message, + String? detail, + String? hint, + String? position, + String? internalPosition, + String? internalQuery, + String? where, + String? schema, + String? table, + String? column, + String? dataType, + String? constraint, + String? file, + String? line, + String? routine, + }) { + return jsify({ + 'severity': severity, + 'code': code, + 'message': message, + if (detail != null) 'detail': detail, + if (hint != null) 'hint': hint, + if (position != null) 'position': position, + if (internalPosition != null) 'internalPosition': internalPosition, + if (internalQuery != null) 'internalQuery': internalQuery, + if (where != null) 'where': where, + if (schema != null) 'schema': schema, + if (table != null) 'table': table, + if (column != null) 'column': column, + if (dataType != null) 'dataType': dataType, + if (constraint != null) 'constraint': constraint, + if (file != null) 'file': file, + if (line != null) 'line': line, + if (routine != null) 'routine': routine, + }) as Notice; + } +} diff --git a/lib/src/query_result.dart b/lib/src/query_result.dart index 19cb16d..eccac89 100644 --- a/lib/src/query_result.dart +++ b/lib/src/query_result.dart @@ -2,12 +2,16 @@ import 'dart:js_interop'; import 'dart:js_util'; import 'package:deno_postgres_interop/src/command_type.dart'; +import 'package:deno_postgres_interop/src/notice.dart'; import 'package:deno_postgres_interop/src/query.dart'; import 'package:deno_postgres_interop/src/row_description.dart'; /// [deno-postgres@v0.17.0/QueryResult](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult). @JS() class QueryResult { + /// [deno-postgres@v0.17.0/QueryResult/warnings](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#prop_warnings). + external List get warnings; + /// [deno-postgres@v0.17.0/QueryResult/constructor](https://deno.land/x/postgres@v0.17.0/query/query.ts?s=QueryResult#ctor_0). external Query get query;