default-value

What is the default value for a field if no default value is provided?

江枫思渺然 提交于 2019-11-30 16:47:19
问题 I hope this isn't a dumb question. You can set a default value for all variables or a function for when it is inserted. but if the field is not required to insert and you don't allow null values, what is the "blank" value that you see in phpMyAdmin? in a query is it returned as empty string, etc? just trying to figure it out, I want to query for all records such that the value for a specific column in that record is not "empty" or blank or whatever. thanks. 回答1: Referring to the manual, For

Is it possible to declare default argument in Java in String? [duplicate]

牧云@^-^@ 提交于 2019-11-30 16:23:33
问题 This question already has answers here : Does Java support default parameter values? (20 answers) Closed 5 years ago . Is it possible to use default argument in the method with String. The code is shown below: public void test(String name="exampleText") { } The code above generate error. Is it possible to correct it? 回答1: No, the way you would normally do this is overload the method like so: public void test() { test("exampleText"); } public void test(String name) { } 回答2: No, it is not.

const reference default-value [duplicate]

南笙酒味 提交于 2019-11-30 14:40:30
问题 This question already has answers here : Closed 6 years ago . Possible Duplicate: how to initialize function arguments that are classes with default value #include <string> void foo1(const std::string& s = std::string()); void foo2(std::string& s = std::string()); void foo3(const std::string s = std::string()); void foo4(std::string s = std::string()); error at foo2(): default argument for ‘std::string& s’ has type ‘std::string {aka std::basic_string<char>}’ I understand the compiler's point,

PostgreSQL - set a default cell value according to another cell value

时光毁灭记忆、已成空白 提交于 2019-11-30 14:31:18
问题 If i have a column say column a of any given values, and i want another column column b to have a default value according to the value of column a In another words: if column a = 'peter' then column b default value = 'doctor' . 回答1: This is not possible with a simple DEFAULT value, as the manual clearly states: The value is any variable-free expression (subqueries and cross-references to other columns in the current table are not allowed). You could use a trigger instead: CREATE OR REPLACE

How to set default values with methods in Odoo?

半城伤御伤魂 提交于 2019-11-30 13:20:08
问题 How to compute the value for default value in object fields in Odoo 8 models.py We can't use the _default attribute anymore in Odoo 8. field_name = fields.datatype( string=’value’, default=compute_default_value ) In the above field declaration, I want to call a method to assign default value for that field. For example: name = fields.Char( string='Name', default= _get_name() ) 回答1: You can use a lambda function like this: name = fields.Char( string='Name', default=lambda self: self._get

How to set the default value of a select box using JQuery in IE9?

跟風遠走 提交于 2019-11-30 13:02:17
I have the following select box. <select id="selId"> <option id='1' value='1'>1</option> <option id='2' value='2'>2</option> <option id='3' value='3'>3</option> <option id='4' value='4'>4</option> <option id='5' value='5'>5</option> </select> In jquery I am doing the following to select the value 2 in the select box.: ... $("select#selId").find("option#2").attr("selected", "selected"); ... The same code sets the value of 2 in the select box in IE8 and Firefox. But its not working in IE9. I am using JQuery 1.6.1 version DavidGouge Instead of setting the selected attribute, just use .val("2").

Check to see if a given object (reference or value type) is equal to its default

和自甴很熟 提交于 2019-11-30 11:55:29
问题 I'm trying to find a way to check and see if the value of a given object is equal to its default value. I've looked around and come up with this: public static bool IsNullOrDefault<T>(T argument) { if (argument is ValueType || argument != null) { return object.Equals(argument, default(T)); } return true; } The problem I'm having is that I want to call it like this: object o = 0; bool b = Utility.Utility.IsNullOrDefault(o); Yes o is an object, but I want to make it figure out the base type and

PHP: bool vs boolean type hinting

≯℡__Kan透↙ 提交于 2019-11-30 11:00:25
I've been trying to use type hinting more in PHP. Today I was writing a function that takes a boolean with a default parameter and I noticed that a function of the form function foo(boolean $bar = false) { var_dump($bar); } actually throws a fatal error: Default value for parameters with a class type hint can only be NULL While a function of the similar form function foo(bool $bar = false) { var_dump($bar); } does not. However, both var_dump((bool) $bar); var_dump((boolean) $bar); give the exact same output :boolean false Why is this? Is this similar to the wrapper classes in Java? Niet the

PostgreSQL - set a default cell value according to another cell value

[亡魂溺海] 提交于 2019-11-30 10:52:59
If i have a column say column a of any given values, and i want another column column b to have a default value according to the value of column a In another words: if column a = 'peter' then column b default value = 'doctor' . This is not possible with a simple DEFAULT value, as the manual clearly states : The value is any variable-free expression (subqueries and cross-references to other columns in the current table are not allowed). You could use a trigger instead: CREATE OR REPLACE FUNCTION trg_foo_b_default() RETURNS trigger AS $func$ BEGIN -- For just a few constant options, CASE does

How can I avoid std::vector<> to initialize all its elements?

蹲街弑〆低调 提交于 2019-11-30 10:50:25
EDIT: I edited both the question and its title to be more precise. Considering the following source code: #include <vector> struct xyz { xyz() { } // empty constructor, but the compiler doesn't care xyz(const xyz& o): v(o.v) { } xyz& operator=(const xyz& o) { v=o.v; return *this; } int v; // <will be initialized to int(), which means 0 }; std::vector<xyz> test() { return std::vector<xyz>(1024); // will do a memset() :-( } ...how can I avoid the memory allocated by the vector<> to be initialized with copies of its first element, which is a O(n) operation I'd rather skip for the sake of speed,