Cannot change to BOOLEAN a column in table using DBeaver - mysql

I have one table in MySQL where I would like to change the "Data type" of two columns in DBeaver (version 22.3.4). The two columns are MD_Estimated and BL_Estimated as you can see in this image:
However, when I save the changes, this is the code which is run:
ALTER TABLE Kruda_Denta_Datumbazo.CrownDiameterTable MODIFY COLUMN MD_Estimated BOOL NULL;
ALTER TABLE Kruda_Denta_Datumbazo.CrownDiameterTable MODIFY COLUMN BL_Estimated BOOL NULL;
But the problem is that it does not return any error, but the "Data type" is not saved as BOOL, but as tinyint(1), as you can see in this image:
Am I doing something wrong?

TINYINT(1) and boolean are synonymous In MySQL. Bool is converted to TINYINT(1) under the hood.

Related

Sequelize & mysql: clause `[tableName].deleted_at IS NULL` getting added automatically

using mysql + sequelize in a React/Node app;
a where the clause below gets automatically added which is screwing up my other where clause statements
[tableName].deleted_at IS NULL
in the nodeJS console, I can see the queries which all have this where clause...
tried recreating indexes, deleting this column throws an error that this field is not available;
column definition is:
`deleted_at` DATETIME NULL DEFAULT NULL,
Sequelize models provide you with a table settings option called paranoid.
In short, it's providing you with a deleted state for each row in that table, and that flag will be included in every query while using the ORM methods to work with the DB on this model.
So when you set the paranoid option to true, deletedAt column will be added as date and time and null as default.
MyModel.init({ /* attributes here */ }, {
sequelize,
paranoid: true,
// If you want to give a custom name to the deletedAt column
deletedAt: 'destroyTime'
});
If you actually check the raw queries, you will find the addition to your WHERE statement WHERE deletedAt IS NULL on all the queries.
You can find out more from the official Sequelize documentation here:
https://sequelize.org/master/manual/paranoid.html

Integrity constraint violation: 1048 Column 'temporary_address' cannot be null error in nullable field

I set the default value for a field on migration but it still gives an error when I left form field temporary_address empty
Is no-value and null is same in laravel? or something else.
my php version: 7.2.15
my mysql version: Ver 14.14 Distrib 5.7.25
My laravel version: 5.7.27
$client->temporary_address = $request->get('temporary_address');
please change this to
if(!empty($request->temporary_address)){
$client->temporary_address = $request->get('temporary_address');
}
i don't know why you decide to not using nullable() on the temporary address, while the other already using nullable
why you got an error ?
Because your temporary_address not accepting null value, and you set default value as an empty string, therefore you got an error like in your post, the solution change the default value to some value, not an empty string or easily make it nullable the best solution.
change this code
$table->string('temporary_address')->default("");
since you already run migration to update it, you need to write it down like this
$table->string('temporary_address')->nullable()->change();
therefore you can left your temporary address empty

error occured while click on table in phpmyadmin

pop-up
some errors have been detected on the server please look at the bottom of this window.
Notice in ./libraries/structure.lib.php#1881
Undefined index: Rows
Backtrace
./libraries/structure.lib.php#2382: getHtmlForRowStatsTable(
array,
NULL,
boolean false,
boolean false,
string '',
string '',
)
./libraries/display_structure.inc.php#263: PMA_getHtmlForDisplayTableStats(
string '',
NULL,
NULL,
boolean false,
NULL,
string '?db=SD&table=sdLogin&token=9d4015ef2a6184f763cb956b670ca8af&goto=tbl_structure.php&back=tbl_structure.php',
NULL,
)
./tbl_structure.php#163: require_once(./libraries/display_structure.inc.php)
It seems any one of two problem occurring in your case:-
Either at the time of installation some problem occur because of that when you are clicking on table this error occur.
either there is some problem at the time of table or database creation.
Solution:-
first try to delete table and try to implode or recreate it.
If not success then try to do the same with its database and then create table.
If again not successful,then try to create another table and check same error happening or not?
If yes then uninstall your xampp/wamp/lamp and reinstalled and check.
Delete database you have created and try to create again.
This error occurs when you have uppercase characters in the tables' names. If you change their names to lowercase, the problem will be gone.

Taking a datetime field into primary key throws fatal error

I would like to use the combination of two foreign keys plus the datetime field as my combined primary key.
But I get a
Catchable Fatal Error: Object of class DateTime could not be converted
to string in
C:\development\xampp\htdocs\happyfaces\vendor\doctrine\orm\lib\Doctrine\ORM\UnitOfWork.php
line 1337
when I do so. As soon as I remove the id: true from my YML entity declaration everything works fine again.
What is the problem that occurs here? It seems to be rather a Symfony2 or a Doctrine2 bug to me, because the datetime is set fine in the database if I don't declare the datetime column to be part of the primary key.
Can anyone help or advise?
Its not possible and not recommended. For primary key focus on primitive data types such as Integer or String. The most RDMS System prefer Integer as primary key for maximum performance.
Take look: http://doctrine-orm.readthedocs.org/en/2.1/tutorials/composite-primary-keys.html
Maybe a workaround could work by adding a new Doctrine data type. With a __toString() function, but I think Doctrine will force you to use primitive data types only.
class Foo
{
private $bar = 'test';
public function __toString()
{
return $this->bar;
}
}
echo new Foo();
Your error means in general DateTime has no __toString() function or is not string compatible. I never tested it to use a custom data type as primary key. So you've to try it yourself.
Take a look: http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/types.html
Another try is use String as Primary key and set your id with
$entity->setId(new \DateTime()->format('yyyy/mm/dd'));
Here is a similar question: Symfony/Doctrine: DateTime as primary key

linq to sql string property from non-null column with default

I have a LINQ to SQL class "VoucherRecord" based on a simple table. One property "Note" is a string that represents an nvarchar(255) column, which is non-nullable and has a default value of empty string ('').
If I instantiate a VoucherRecord the initial value of the Note property is null. If I add it using a DataContext's InsertOnSubmit method, I get a SQL error message:
Cannot insert the value NULL into column 'Note', table 'foo.bar.tblVoucher'; column does not allow nulls. INSERT fails.
Why isn't the database default kicking in? What sort of query could bypass the default anyway? How do I view the generated sql for this action?
Thanks for your help!
If you omit the column, the value becomes the database default, but anything you insert is used instead of the default, example:
INSERT INTO MyTable (ID, VoucherRecord) Values(34, NULL) -- Null is used
INSERT INTO MyTable (ID) Values(34) -- Default is used
Picture for example you have a column that defaults to anything but NULL, but you specifically want NULL...for that to ever work, whatever value you specify MUST override the default, even in the case of NULL.
You need to set Auto-Sync to OnInsert, Auto Generated Value to true and Nullable to false for your column to work. See here for a full run-down with explanation on the Linq side.
For viewing the generated SQL, I have to recommend LinqPad