nested

MYSQL WHERE-IN Subquery Runs Forever

南楼画角 提交于 2019-12-22 04:42:28
问题 I have a MySQL table. Let's call it Widgets. The Widget table has 3 fields: id , type_id , and name . I want, in one query, to get all the widgets that share a type_id with the Widget named 'doodad'. I've written 2 queries: Give me the type_id of the widget with the name 'doodad'. Give me all widgets with that type_id. This works. Each query, independently achieves its goal. But when I combine them into a single nested query, it runs forever, infinite loop style. It looks like this: SELECT *

MYSQL WHERE-IN Subquery Runs Forever

你。 提交于 2019-12-22 04:42:06
问题 I have a MySQL table. Let's call it Widgets. The Widget table has 3 fields: id , type_id , and name . I want, in one query, to get all the widgets that share a type_id with the Widget named 'doodad'. I've written 2 queries: Give me the type_id of the widget with the name 'doodad'. Give me all widgets with that type_id. This works. Each query, independently achieves its goal. But when I combine them into a single nested query, it runs forever, infinite loop style. It looks like this: SELECT *

Casting a generic dictionary containing a generic dictionary

99封情书 提交于 2019-12-22 04:34:06
问题 I have: var someConcreteInstance = new Dictionary<string, Dictionary<string, bool>>(); and I wish to cast it to an interface version, i.e.: someInterfaceInstance = (IDictionary<string, IDictionary<string, bool>>)someConcreteInstance; 'someInterfaceInstance' is a public property: IDictionary<string, IDictionary<string, bool>> someInterfaceInstance { get; set; } This compiles correctly, but throws a runtime casting error. Unable to cast object of type 'System.Collections.Generic.Dictionary`2

Closing a nested stream closes its parent streams too?

我与影子孤独终老i 提交于 2019-12-22 04:31:09
问题 OutputStream fos; OutputStream bos; OutputStream zos; try { fos = new FileOutputStream(anyFile); bos = new BufferedOutputStream(fos); zos = new ZipOutputStream(bos); } finally { if (zos != null) { zos.close(); // + exception handling } } Does closing zos automatically closes bos and fos too, or do I need to close them manually? 回答1: Yes, it does. Its Javadoc says: Closes the ZIP output stream as well as the stream being filtered. Also, the Javadoc for BufferedOutputStream says: Closes this

Jasper list element inside table element with XML datasource

懵懂的女人 提交于 2019-12-22 04:03:29
问题 I'm trying to generate a report, using Jasper iReport Designer 5.6.0 , with table that contains lists inside its cells. The generated table could look like this: To do this, I'm using the following XML file as datasource: <report> <table> <persons> <person> <id>111</id> <name>John</name> <addresses> <address>Johan's Street 1</address> <address>Johan's Street 2</address> <address>Johan's Street 3</address> </addresses> </person> <person> <id>222</id> <name>Marko</name> <addresses> <address

Overloading operator<< for a nested private class possible?

烈酒焚心 提交于 2019-12-22 03:53:09
问题 How one can overload an operator<< for a nested private class like this one? class outer { private: class nested { friend ostream& operator<<(ostream& os, const nested& a); }; // ... }; When trying outside of outer class compiler complains about privacy: error: ‘class outer::nested’ is private 回答1: You could make the operator<< a friend of outer as well. Or you could implement it completely inline in nested , e.g.: class Outer { class Inner { friend std::ostream& operator<<( std::ostream&

How to convert nested List into multidimensional array?

天大地大妈咪最大 提交于 2019-12-22 00:06:54
问题 In Java I want to convert a nested List which contains at the deepest level a uniform type into an multidimensional array of that type. For example, ArrayList<ArrayList<ArrayList<ArrayList<String>>>> into String[][][][] . I've tried several things and I only can obtain an array of objects like Object[][][][] . For 'simple lists' it seems that Apache Commons Lang does the work but I cannot figure out for nested cases. Update: In order to obtain a multidimensional array of Object type I'm using

How to convert nested JSON to CSV using only jq

安稳与你 提交于 2019-12-21 23:16:54
问题 I've following json, { "A": { "C": { "D": "T1", "E": 1 }, "F": { "D": "T2", "E": 2 } }, "B": { "C": { "D": "T3", "E": 3 } } } I want to convert it into csv as follows, A,C,T1,1 A,F,T2,2 B,C,T3,3 Description of output: The parents keys will be printed until, I've reached the leaf child. Once I reached leaf child, print its value. I've tried following and couldn't succeed, cat my.json | jq -r '(map(keys) | add | unique) as $cols | map(. as $row | $cols | map($row[.])) as $rows | $rows[] | @csv'

Nested JSON From PHP Array

筅森魡賤 提交于 2019-12-21 21:39:48
问题 I've loaded my iTunes song data into a MySQL database and I'm trying to use PHP to get a JSON feed of album information. This code.. <?php /* Connect to database */ require ('include/connect.php'); /* Build the query */ $query = "SELECT a.album,a.name,a.artist,a.year AS track_year, b.year AS album_year FROM staging a, (SELECT album, MAX(year) AS year FROM staging GROUP BY album) b WHERE a.album = b.album"; /* Loop through the results and build a JSON array for the data table */ $result =

No route matches with Nested Resources

霸气de小男生 提交于 2019-12-21 21:33:10
问题 I have two associated tables. Venues and Specials . A venue can have many specials . Once a user has created a venue I wish to allow them to create a special on the venues#index page. By using nested resources I have achieved the desired URL: /venues/5/specials/new . However, my current code results with: No route matches {:controller=>"specials", :format=>nil} I'm guessing the error is with my SpecialsController and the def new and def create functions. I would like the URL to take me to a