def test_execute_select(mocked_connection, mocked_cursor, mocker):
    mocked_cursor.description = 1, 1, 1, 1, 1, 1, 1
    mocked_cursor.fetchall.side_effect = [((1, 'abc'),)]
    dummy = MySQLJDBC(mocked_connection, transaction_id='123')
    dummy.create_column_metadata_set = create_column_metadata_set_mock = mocker.Mock()
    create_column_metadata_set_mock.side_effect = [
        [
            ColumnMetadata(
                arrayBaseColumnType=0,
                isAutoIncrement=False,
                isCaseSensitive=False,
                isCurrency=False,
                isSigned=False,
                label=1,
                name=1,
                precision=5,
                scale=6,
                tableName=None,
                type=None,
                typeName=None,
            ),
            ColumnMetadata(
                arrayBaseColumnType=0,
                isAutoIncrement=False,
                isCaseSensitive=False,
                isCurrency=False,
                isSigned=False,
                label=8,
                name=8,
                precision=12,
                scale=13,
                tableName=None,
                type=None,
                typeName=None,
            ),
        ]
    ]

    assert dummy.execute("select * from users",) == ExecuteStatementResponse(
        numberOfRecordsUpdated=0,
        records=[[dummy.get_field_from_value(1), dummy.get_field_from_value('abc')]],
    )

    mocked_cursor.execute.assert_has_calls(
        [mocker.call('SELECT LAST_INSERT_ID(NULL)'), mocker.call('select * from users')]
    )
    mocked_cursor.close.assert_called_once_with()
def test_execute_select(mocked_connection, mocked_cursor, mocker):
    mocked_cursor.description = 1, 1, 1, 1, 1, 1, 1
    mocked_cursor.fetchall.side_effect = [((1, 'abc'), )]
    dummy = MySQLJDBC(mocked_connection, transaction_id='123')
    assert dummy.execute("select * from users", ) == ExecuteStatementResponse(
        numberOfRecordsUpdated=0,
        records=[[
            dummy.get_field_from_value(1),
            dummy.get_field_from_value('abc')
        ]],
    )

    mocked_cursor.execute.assert_has_calls([
        mocker.call('SELECT LAST_INSERT_ID(NULL)'),
        mocker.call('select * from users')
    ])
    mocked_cursor.close.assert_called_once_with()
def test_from_value(mocker) -> None:
    connection_mock = mocker.Mock()
    dummy = MySQLJDBC(connection_mock)

    class BigInteger:
        def __init__(self, val: int):
            self._val: int = val

        def __str__(self) -> int:
            return self._val

    assert dummy.get_field_from_value(BigInteger("55")) == Field(longValue=55)

    helper_default_test_field(dummy)