Skip to content

Commit dfcdba3

Browse files
committed
Code formatting, doc and test updates
1 parent 8862ce9 commit dfcdba3

File tree

19 files changed

+790
-512
lines changed

19 files changed

+790
-512
lines changed

doc/src/api_manual/connection.rst

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1365,28 +1365,25 @@ Connection Methods
13651365

13661366
Each column’s ``name`` is always given. If the column is a :ref:`nested cursor <nestedcursors>`, then the column’s object will also contain a ``metaData`` attribute which is an array describing each column in the nested query.
13671367

1368-
Extended metadata is now always returned and includes the following information:
1369-
1370-
- ``annotations``: The `annotations <https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/annotations_clause.html#GUID-1AC16117-BBB6-4435-8794-2B99F8F68052>`__ object associated with the fetched column. If the column has no associated annotations, this property value is `undefined`. Annotations are supported from Oracle Database 23ai onwards. If node-oracledb Thick mode is used, Oracle Client 23ai is also required.
1368+
Extended metadata is now always returned and includes the following information attributes:
13711369

1370+
- ``annotations``: The `annotations <https://docs.oracle.com/en/database/oracle/oracle-database/23/sqlrf/annotations_clause.html#GUID-1AC16117-BBB6-4435-8794-2B99F8F68052>`__ object associated with the fetched column. If the column has no associated annotations, this attribute value is `undefined`. Annotations are supported from Oracle Database 23ai onwards. If node-oracledb Thick mode is used, Oracle Client 23ai is also required.
13721371
- ``byteSize``: The database byte size. This is only set for ``oracledb.DB_TYPE_VARCHAR``, ``oracledb.DB_TYPE_CHAR`` and ``oracledb.DB_TYPE_RAW`` column types.
13731372
- ``dbType``: one of the :ref:`Oracle Database Type Constant <oracledbconstantsdbtype>` values.
13741373
- ``dbTypeClass``: The class associated with the database type. This is only set if the database type is an object type.
13751374
- ``dbTypeName``: The name of the database type, such as “NUMBER” or “VARCHAR2”. For object types, this will be the object name.
1376-
- ``domainName``: The name of the `data use case domain <https://www.oracle.com/pls/topic/lookup?ctx=dblatest&id=GUID-17D3A9C6-D993-4E94-BF6B-CACA56581F41>`__ associated with the fetched column. If the column does not have a data use case domain, this property value is `undefined`. `Data use case domains <https://www.oracle.com/pls/topic/lookup?ctx=dblatest&id=GUID-4743FDE1-7C6E-471B-BC9D-442383CCA2F9>`__ are supported from Oracle Database 23ai onwards. If node-oracledb Thick mode is used, Oracle Client 23ai is also required.
1377-
1378-
- ``domainSchema``: The schema name of the `data use case domain <https://www.oracle.com/pls/topic/lookup?ctx=dblatest&id=GUID-17D3A9C6-D993-4E94-BF6B-CACA56581F41>`__ associated with the fetched column. If the column does not have a data use case domain, this property value is `undefined`. `Data use case domains <https://www.oracle.com/pls/topic/lookup?ctx=dblatest&id=GUID-4743FDE1-7C6E-471B-BC9D-442383CCA2F9>`__ are supported from Oracle Database 23ai onwards. If node-oracledb Thick mode is used, Oracle Client 23ai is also required.
1379-
1375+
- ``domainName``: The name of the `data use case domain <https://www.oracle.com/pls/topic/lookup?ctx=dblatest&id=GUID-17D3A9C6-D993-4E94-BF6B-CACA56581F41>`__ associated with the fetched column. If the column does not have a data use case domain, this attribute value is `undefined`. `Data use case domains <https://www.oracle.com/pls/topic/lookup?ctx=dblatest&id=GUID-4743FDE1-7C6E-471B-BC9D-442383CCA2F9>`__ are supported from Oracle Database 23ai onwards. If node-oracledb Thick mode is used, Oracle Client 23ai is also required.
1376+
- ``domainSchema``: The schema name of the `data use case domain <https://www.oracle.com/pls/topic/lookup?ctx=dblatest&id=GUID-17D3A9C6-D993-4E94-BF6B-CACA56581F41>`__ associated with the fetched column. If the column does not have a data use case domain, this attribute value is `undefined`. `Data use case domains <https://www.oracle.com/pls/topic/lookup?ctx=dblatest&id=GUID-4743FDE1-7C6E-471B-BC9D-442383CCA2F9>`__ are supported from Oracle Database 23ai onwards. If node-oracledb Thick mode is used, Oracle Client 23ai is also required.
13801377
- ``fetchType``: One of the :ref:`Node-oracledb Type Constant <oracledbconstantsnodbtype>` values.
13811378
- ``isJson``: Indicates if the column is known to contain JSON data. This will be ``true`` for JSON columns (from Oracle Database 21c) and for LOB and VARCHAR2 columns where "IS JSON" constraint is enabled (from Oracle Database 19c). This property will be ``false`` for all the other columns. It will also be ``false`` for any column when Oracle Client 18c or earlier is used in Thick mode or the Oracle Database version is earlier than 19c.
13821379
- ``isOson``: Indicates if the column is known to contain binary encoded OSON data. This attribute will be ``true`` in Thin mode and while using Oracle Client version 21c (or later) in Thick mode when the "IS JSON FORMAT OSON" check constraint is enabled on BLOB and RAW columns. It will be set to ``false`` for all other columns. It will also be set to ``false`` for any column when the Thick mode uses Oracle Client versions earlier than 21c. Note that the "IS JSON FORMAT OSON" check constraint is available from Oracle Database 19c onwards.
13831380
- ``isSparseVector``: Indicates if the column is known to contain a sparse vector. This will be ``true`` for vector columns containing sparse vectors.
1384-
- ``name``: The column name follows Oracle’s standard name-casing rules. It will commonly be uppercase, since most applications create tables using unquoted, case-insensitive names.
1381+
- ``name``: The unique column name chosen by node-oracledb. It follows Oracle’s standard name-casing rules. It will commonly be uppercase, since most applications create tables using unquoted, case-insensitive names. If the query does not contain duplicate columns, this value will be the same as the actual database column name. If the query contains duplicate columns, the this attribute will create unique column names by appending an underscore and a unique number.
13851382
- ``nullable``: Indicates whether ``NULL`` values are permitted for this column.
13861383
- ``precision``: Set only for ``oracledb.DB_TYPE_NUMBER``, ``oracledb.DB_TYPE_TIMESTAMP``, ``oracledb.DB_TYPE_TIMESTAMP_TZ``, and ``oracledb.DB_TYPE_TIMESTAMP_LTZ`` columns.
13871384
- ``scale``: Set only for ``oracledb.DB_TYPE_NUMBER`` columns.
1388-
- ``vectorDimensions``: The number of dimensions of the VECTOR column. If the column is not a VECTOR column or allows for any number of dimensions, then the value of this property is *undefined*.
1389-
- ``vectorFormat``: The storage format of each dimension value in the VECTOR column. If the column is not a VECTOR column or allows for any storage format, then the value of this property is *undefined*.
1385+
- ``vectorDimensions``: The number of dimensions of the VECTOR column. If the column is not a VECTOR column or allows for any number of dimensions, then the value of this attribute is *undefined*.
1386+
- ``vectorFormat``: The storage format of each dimension value in the VECTOR column. If the column is not a VECTOR column or allows for any storage format, then the value of this attribute is *undefined*.
13901387

13911388
.. versionchanged:: 6.8
13921389

doc/src/user_guide/bind.rst

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,32 @@ and ``:country_name`` are the two bind variables in this SQL statement:
1919
{country_id: 90, country_name: "Tonga"}
2020
);
2121
22-
IN binds are values passed into the database. OUT binds are used to
23-
retrieve data. IN OUT binds are passed in, and may return a different
24-
value after the statement executes.
22+
As part of execution, the supplied bind variable values ``90`` and
23+
``"Tonga"`` are substituted for the placeholders by the database. This is
24+
called binding.
2525

26-
.. note::
26+
Using bind variables is important for scalability and security. They help
27+
avoid SQL Injection security problems because data is never treated as part of
28+
an executable statement when it is parsed.
2729

28-
Using bind parameters is recommended in preference to constructing SQL or
29-
PL/SQL statements by string concatenation or template literals. This is
30-
for performance and security.
30+
Bind variables reduce parsing and execution costs when statements are executed
31+
more than once with different data values. If you do not use bind variables,
32+
Oracle must reparse and cache multiple statements. When using bind variables,
33+
Oracle Database may be able to reuse the statement execution plan and context.
34+
35+
.. important::
36+
37+
Never concatenate or interpolate user data into SQL statements.
38+
39+
.. code-block:: javascript
40+
41+
const did = 280;
42+
const dnm = "Facility";
43+
44+
// !! Never do this !!
45+
const sql = `INSERT INTO departments (department_id, department_name)
46+
VALUES ({did}, '{dnm}')`;
47+
await connection.execute(sql);
3148
3249
Inserted data that is bound is passed to the database separately from
3350
the statement text. It can never be executed directly. This means there
@@ -44,6 +61,9 @@ used for direct substitution of column or table names in dynamically
4461
constructed statements, see :ref:`Binding Column and Table Names in
4562
Queries <sqlbindtablename>`.
4663

64+
Bind parameters can be :ref:`IN <inbind>`, :ref:`OUT <outbind>`, or
65+
:ref:`IN OUT <outbind>` and are detailed in the subsequent sections.
66+
4767
Bind variables cannot be used in `DDL <https://www.oracle.com/pls/topic/
4868
lookup?ctx=dblatest&id=GUID-FD9A8CB4-6B9A-44E5-B114-EFB8DA76FC88>`__
4969
statements, for example ``CREATE TABLE`` or ``ALTER`` commands.

0 commit comments

Comments
 (0)