Comment by Schwern on How to prevent password from being updated if empty in...
You get the same result with or without allow_nil. Demonstration. And your question wasn't about nil, update your question please.
View ArticleWhy don't PHP attributes allow functions?
I'm pretty new to PHP, but I've been programming in similar languages for years. I was flummoxed by the following:class Foo { public $path = array( realpath(".") );}It produced a syntax error: Parse...
View ArticleComment by Schwern on Error converting the varchar to data type INT
An explanation would make this a better answer.
View ArticleComment by Schwern on Why would `has_secure_password` suppress password...
That explains why it's happening, thanks. Does it seem deliberate? What is your opinion about this being a bug/undesirable behavior?
View ArticleComment by Schwern on Error converting the varchar to data type INT
Are you using Microsoft's "SQL Server"?
View ArticleComment by Schwern on Error converting the varchar to data type INT
@Kkoruni I've added an example of use with try_cast. Garbage was stored in Sales because the data type of varchar(20) allowed it. To avoid this, use the most restrictive and appropriate data type and...
View ArticleWhy would `has_secure_password` suppress password validation on update, but...
Let's say I have a simple model like so with a presence validation on the password field.class User < ApplicationRecord validates :password, presence: trueendIf I try to update the password to a...
View ArticleAnswer by Schwern for SELECT INTO does not raise exception when no row is found
For select to raise NO_DATA_FOUND you must use the strict option. The intent is when you expect exactly ONE row to be returned.If the STRICT option is specified, the command must return exactly one row...
View ArticleComment by Schwern on How to find all the commits of an organization in github?
Start the process now, it might finish before you get a better solution.
View ArticleAnswer by Schwern for How to find all the commits of an organization in github?
A faster option might be to use the Github API to list all public repositories of an organization. For each repository only clone the commits using git clone --filter=object:type=commit. Then use git...
View ArticleAnswer by Schwern for SQL: Combining 'or','and', and 'order by'
where and order by and limit are separate clauses in the statement. Good indentation helps.You want to make it clear that it is where (x and y) or z not where x and (y or z).Select * From interview...
View ArticleAnswer by Schwern for Unable to insert or update data using Python into...
Each row you're inserting must be wrapped in parens.insert into table(a,b,c) values (1,2,3);See SQL tutorial: INSERT.Two notes. First, don't concatenate SQL values as strings. This leaves you...
View ArticleAnswer by Schwern for Create shell and then execute commands
You're using sh -c which takes commands as arguments.You're trying to pass in a command on stdin.From the bash man page.-c If the -c option is present, then commands are read from the first non-option...
View ArticleAnswer by Schwern for why mysql change my code view?
What you're seeing is issues resulting from the SQL being compiled and then decompiled.human readable SQL -> compiled form -> human readable SQLDon't worry, it's all equivalent code. If you want...
View ArticleComment by Schwern on Pushing changes in Git: "Your branch and...
git log --graph --decorate --oneline --all will show you the true state of your repository. Or use a visualization tool like GitKraken.
View ArticleComment by Schwern on Pushing changes in Git: "Your branch and...
@Anna And it should have told you how to fix that. Please commit your changes or stash them before you switch branches. Either commit your changes, stash them for later, or throw out the changes.
View ArticleComment by Schwern on Why is my brand new MacBook Pro so slowly (it took...
There should be a log file which will tell you what it's doing.
View ArticleComment by Schwern on How to test a C pointer for whether it points to a struct
@Addem C lacks the sort of protections you're looking for coming from other languages. You're responsible for making sure data structures are initialized. Instead, use tools such as valgrind and memory...
View ArticleComment by Schwern on Measuring actual indefiniteness of undefined behavior...
Since undefined behavior is undefined, it will depend on the compiler, OS, hardware, versions of all of that, and phase of the moon.
View ArticleAnswer by Schwern for Measuring actual indefiniteness of undefined behavior...
Can anyone provide me with evidence that this simple code from cases 4-5 can actually show an undefined behavior at any circumstances? On any machine controlled by any OS inside any program.Exhibit A....
View Article